UEditor有一个功能叫切换16进制模式;
我输入汉字 "晨",点击按钮“切换到16进制模式”,可以查看到 “晨”字对应的编码为 B3BF
那么java通过什么方法可以将B3BF转化为汉字"晨" ????
在线等~~~~~~~~~~~~~~~~~~~~~~~~~~~ 别随意赋值网上帖子,谢谢!
------解决方案--------------------
学习很大程度上靠百度谷歌的,不可否认。百度一大堆
public static String hexToStringGBK(String s) {
byte[] baKeyword = new byte[s.length() / 2];
for (int i = 0; i < baKeyword.length; i++) {
try {
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
try {
s = new String(baKeyword, "GBK");// UTF-16le:Not
} catch (Exception e1) {
e1.printStackTrace();
return "";
}
return s;
}