日期:2014-05-17 浏览次数:20710 次
public static void main(String[] args) {
String s = "\\u4e2d\\u56fd";
//s = s.replace("\\u", "\u");
s = s.replace("\\\\u", "\\u");
System.out.println(s);
}
String s = "China\\u4e2d+\\u56fdRMB";
StringBuilder sbRet = new StringBuilder(s.length()); // 存放结果的
for (int i = 0; i < s.length(); i++) {
if ('\\' == s.charAt(i)) { // 把"\\uXXXX"的字符找出来,转义
if ((i + 1 < s.length()) && 'u' == s.charAt(i + 1)) {
int start = i + 1 + 1;
int end = start + 4;
if (end <= s.length()) {
String strHex = s.substring(start, end);
sbRet.append((char) Integer.parseInt(strHex, 16));
i = end - 1;
}
}
&n