更新时间:2023-02-14 11:32:02
20B9
是Unicode点值. IE. U + 20B9.它不是经过编码的,也不是UTF-8.
20B9
is a Unicode point value. I.e. U+20B9. It's not encoded and not UTF-8.
尝试currencySymbol.getBytes("UTF-8")
是毫无意义的,因为您的字符串已经从字节中解码出来了-您将得到的只是十六进制字符串的ASCII字节,因此您将获得响应.
It's pointless trying to currencySymbol.getBytes("UTF-8")
as your string has already been decoded from bytes - all you will get is the ASCII bytes of the string of the hex, hence the response you're getting.
相反,您需要:
示例:
int codepoint = Integer.parseInt(currency.getSymbol(), 16);
char[] currencySymbol =Character.toChars(codepoint);