public static void main(String[] args) throws UnsupportedEncodingException {
// Unicode转中文
String unicode1 = “”;
String result = new String(unicode1.getBytes(“UTF-8”), “UTF-8”);
System.out.println(result);
中文转Unicode
String chinese = “”;
StringBuffer unicode = new StringBuffer();
for (int i = 0; i < chinese.length(); i++) {
Character character = chinese.charAt(i);
unicode.append(“\u” + Integer.toHexString(character));
}
System.out.println(unicode.toString());
}
本人已亲测
Unicode和中文互转
最新推荐文章于 2023-12-21 09:05:02 发布