Java将Unicode转换成中文

Java代码:

public static String unicodeToString(String str) {
        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
        Matcher matcher = pattern.matcher(str);
        char ch;
        while (matcher.find()) {
            ch = (char) Integer.parseInt(matcher.group(2), 16);
            str = str.replace(matcher.group(1), ch+"" );
        }
        return str;
    }

原文地址:https://blog.csdn.net/u013066244/article/details/54708179
仅供学习交流,侵删

posted on 2019-09-24 17:14  爱你的铁锤妹妹  阅读(202)  评论(0编辑  收藏  举报