[英]how to convert unicode characters to actual characters in java?
我要輸入兩個字符串:1.簿記表格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á
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.