我有两个字符串: 1.记账表格\\u0026模板 2.霍奇金病
我想用 & 替换\\u0026,用 ' 替换\u0027。一种方法是用相应的符号替换它们的出现,但是有没有通用的方法来处理这个问题?
最佳答案
我的推荐是 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á
关于java - java中如何将unicode字符转换为实际字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47995034/