读书人

unicode 转汉语言

发布时间: 2012-07-02 17:46:23 作者: rapoo

unicode 转中文

public class Conversion {
?public static String convert(String source) {
??if (null == source || " ".equals(source)) {
???return source;
??}

??StringBuffer sb = new StringBuffer();
??int i = 0;
??while (i < source.length()) {
???if (source.charAt(i) == '\\') {
????int j = Integer.parseInt(source.substring(i + 2, i + 6), 16);
????sb.append((char) j);
????i += 6;
???} else {
????sb.append(source.charAt(i));
????i++;
???}
??}
??return sb.toString();
?}

}

读书人网 >行业软件

热点推荐