java - java中如何将unicode字符转换为实际字符?

标签 java string character-encoding url-encoding

我有两个字符串: 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

enter image description here

该方法将 unicode 转换为可读文本,例如:

String stringWithUnicode; //For example "tendr\\u00e1"
StringScapeUtils.unescapeJava(stringWithUnicode); //This call returns: Tendrá

关于java - java中如何将unicode字符转换为实际字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47995034/

相关文章:

PHP 将 Windows-1256 编码的文本转换为 UTF-8

c - 在 C 中分配字符 'æ' 、 'ø' 或 'å'

python - 在 Python 中处理 UTF-8 数字

Java Session失效和超时不起作用

java - java 和 Scala 中非 Ascii 字符的子字符串

python - 使用解析/切片子字符串的内容实例化对象属性?

c++ - 在 C++ 中循环遍历字符串

java - 如何让一个jsp页面下载2个文件

java - 如果我有一个 Java 树,并将根设置为 NULL,所有节点都会被垃圾收集吗?

java - 如何使用多个 Controller 或如何正确使用 Apache Tiles?