package com.wx.application.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;

import cn.hutool.http.HtmlUtil;

public class UnicodeDecode {
	
	public static String convertUnicodeToCh(String str) {
		
		if(StringUtils.isBlank(str)) {
			return str;
		}
		
		str = HtmlUtil.cleanHtmlTag(str);
		str = str.replaceAll("&nbsp;", "");
		
        Pattern pattern = Pattern.compile("(\\\\u(\\w{4}))");
        Matcher matcher = pattern.matcher(str);
 
        while (matcher.find()) {
            String unicodeFull = matcher.group(1);
            String unicodeNum = matcher.group(2);
            char singleChar = (char) Integer.parseInt(unicodeNum, 16);
            str = str.replace(unicodeFull, singleChar + "");
        }
        return str;
    }
	
}
