我是 Java 新手,过去一小时一直在通过 google-fu 广告实验来解决这个问题。我需要将 s1 转换为 s2,其中 s1 和 s2 是:
String s1 ="\\u00C1";
//...
String s2 ="Á";
最佳答案
您需要扫描字符串以找到“\u”部分,然后将以下四个字符提取到一个单独的字符串中,然后使用 Integer.parseInt(String s, int radix)
和基数 16 将 00C1
转换为 int
,然后将该 int
转换为 char
。
关于java - 将类 Unicode 字符串转换为真正的 Unicode 字符串的最短代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8829161/