android简繁体相互转换
简繁体相互转换,首先我们要引入一个包:jcc-bate-0.7.3.jar。
我们先来看下这个包的结构:
由图我们知道,通过JChineseConvertor.getInstance();可以得到实例,再通过s2t和t2s方法可以进行转化。
s2t方法就是将简体转换成繁体,t2s方法就是将繁体转换成简体。
[java] ?//简体转成繁体
public String change(String changeText) {
try {
JChineseConvertor jChineseConvertor = JChineseConvertor
.getInstance();
changeText = jChineseConvertor.s2t(changeText);
} catch (IOException e) {
e.printStackTrace();
}
return changeText;
}
//繁体转成简体
public String change1(String changeText) {
try {
JChineseConvertor jChineseConvertor = JChineseConvertor
.getInstance();
changeText = jChineseConvertor.t2s(changeText);
} catch (IOException e) {
e.printStackTrace();
}
return changeText;
}
//简体转成繁体
public String change(String changeText) {
try {
JChineseConvertor jChineseConvertor = JChineseConvertor
.getInstance();
changeText = jChineseConvertor.s2t(changeText);
} catch (IOException e) {
e.printStackTrace();
}
return changeText;
}
//繁体转成简体
public String change1(String changeText) {
try {
JChineseConvertor jChineseConvertor = JChineseConvertor
.getInstance();
changeText = jChineseConvertor.t2s(changeText);
} catch (IOException e) {
e.printStackTrace();
}
return changeText;
}
补充:移动开发 , Android ,