标签:byte unicode nic out int i++ sys string str
String str = "中文转unicode";
char[] utfBytes = str.toCharArray();
String unicodeBytes = "";
for (int i = 0; i < utfBytes.length; i++) {
String hexB = Integer.toHexString(utfBytes[i]);
if (hexB.length() <= 2) {
hexB = "00" + hexB;
}
unicodeBytes = unicodeBytes + "\\u" + hexB;
}
System.out.println(unicodeBytes);
标签:byte unicode nic out int i++ sys string str
原文地址:https://www.cnblogs.com/it-yong/p/11468500.html