UnicodeUtil.java 589 B

12345678910111213141516171819202122
  1. package info.aspirecn.iov.sjjh.supplier10000057.util;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4. /**
  5. * @author xusonglin
  6. * @version V1.0
  7. **/
  8. public class UnicodeUtil {
  9. private static Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
  10. public static String unicodeToString(String str) {
  11. Matcher matcher = pattern.matcher(str);
  12. char ch;
  13. while (matcher.find()) {
  14. ch = (char) Integer.parseInt(matcher.group(2), 16);
  15. str = str.replace(matcher.group(1), ch + "");
  16. }
  17. return str;
  18. }
  19. }