It's simple, I would like to convert the string characters into Unicode.
EG:
String txt = "fiancé bla";
System.out.println("Converted: " + someMethod(txt) );
The output I'm looking for is: Converted: fianc\é bla
. How can I do that?
Thanks in advance.
Use Apache Commons Lang3 library, specifically StringEscapeUtils.escapeJava(String) :
public static void main(String[] args) {
System.out.println(StringEscapeUtils.escapeJava("fiancé bla"));
//outputs fianc\u00E9 bla
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.