@Override
public String getUnicode16(String gbk) {
StringBuilder contentUnicode16 = new StringBuilder();
try {
int length = gbk.getBytes(StandardCharsets.UTF_16).length;
String temp = "";
byte[] bytesContent ;
bytesContent = gbk.getBytes(StandardCharsets.UTF_16);
contentUnicode16 = new StringBuilder();
for (int i = 2; i < length; i++) {
temp = Integer.toHexString(bytesContent[i]);
if (temp.length() < 2) {
temp = "0" + temp;
}
contentUnicode16.append(temp.substring(temp.length() - 2));
}
} catch (Exception e) {
log.info(e.getMessage(), e);
}
return contentUnicode16.toString();
GBK转换为Unicode的十六进制
最新推荐文章于 2025-03-20 11:46:48 发布