[英]How to convert decimal codepoint to UTF-16 Hex (java Syntax)?
When you say "into UTF-16 Hex 0xE056
", it's unclear whether you mean the string 0xE056
or the char
character with that value. 当您说“成UTF-16十六进制
0xE056
”时,不清楚是指字符串0xE056
还是具有该值的char
字符。
To convert a string 57430
to an integer: 要将字符串
57430
转换为整数:
int value = Integer.parseInt("57430");
To convert to hex string: 转换为十六进制字符串:
String hex = Integer.toHexString(value); // e056
String hex = Integer.toHexString(value).toUpperCase(); // E056
String hex = String.format("0x%04x", value); // 0xe056
String hex = String.format("0x%04X", value); // 0xE056
To convert to char
: 转换为
char
:
char ch = (char)value; // Only for 0-65535
char[] ch = Character.toChars(value); // For any codepoint
To convert to String
: 转换为
String
:
String symbol = new String(Character.toChars(value)); // For any codepoint
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.