转载将汉字用UTF-8重新编码,
作者(不详)public String GB2312ToUTF8(String gbk) {
String res = null;
StringBuffer buf = new StringBuffer();
try {
char[] chr = gbk.toCharArray();
for(int index=0;index<chr.length;index++) {
String str = Integer.toHexString((int) chr[index]);
buf.append("&#x" + str + ";");
}
res = buf.toString();
} catch(Exception ex) {
ex.printStackTrace();
}
return res;
}
作者(不详)public String GB2312ToUTF8(String gbk) {
String res = null;
StringBuffer buf = new StringBuffer();
try {
char[] chr = gbk.toCharArray();
for(int index=0;index<chr.length;index++) {
String str = Integer.toHexString((int) chr[index]);
buf.append("&#x" + str + ";");
}
res = buf.toString();
} catch(Exception ex) {
ex.printStackTrace();
}
return res;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货