与其他厂家对接接口的时候,返回描述为unicode码,看着特别扭,参考资料,转换成我们可以看懂的汉字。
返回的参数:
参数:unicode码 ,直接返回汉字
private static String asciiToNative(String asciicode) {
String[] asciis = asciicode.split("\\\\u");
String nativeValue = asciis[0];
try {
for (int i = 1; i < asciis.length; i++) {
String code = asciis[i];
nativeValue += (char) Integer.parseInt(code.substring(0, 4), 16);
if (code.length() > 4) {
nativeValue += code.substring(4, code.length());
}
}
} catch (NumberFormatException e) {
return asciicode;
}
return nativeValue;
}