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();
 }

}

猜你喜欢

转载自zhangjialu-vip.iteye.com/blog/1165635