如何将unicode字符转换为java中的实际字符?
问题描述:
我有两个字符串: 1.记账形式\\ u0026模板 2.霍奇金\提供上门疾病如何将unicode字符转换为java中的实际字符?
我想&与” \ u0027更换\\ u0026。其中一种方式是用相应的符号替换它们的出现,但是有没有一种通用的方法来处理这个问题?
答
我的建议是Apache StringScapeUtils
特别是unescapeJava
方法。
网站:https://commons.apache.org/proper/commons-lang/
Maven的回购:https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
这种方法转换UNICODE到可读文本,例如:
String stringWithUnicode; //For example "tendr\\u00e1"
StringScapeUtils.unescapeJava(stringWithUnicode); //This call returns: Tendrá
请检查此链接HTTPS :// STAC koverflow.com/questions/11145681/how-to-convert-a-string-with-unicode-encoding-to-a-string-of-letters –
这些字符串在哪里?他们来自哪里? –
他们来自http请求的json。 –