简体   繁体   中英

How can I convert accented characters to HTML symbol in Java?

I wrote a program in Java that reads through a Localizable.strings file for iOS localization and creates the counterpart for Android. The iOS files allow special characters, like accented characters (è, é, etc), but for Android these should be converted to decimal unicode representation (and included in an xml file).

When I grab the value from the Localizable.strings file, I attempt to replace these symbols using the following code:

value = value.replace("...", "…")
             .replace("'", "\\'")
             .replace("’", "\\'")
             .replace("è", "è")
             .replace("é", "é");

This successfully replaces ... , ' , and ' , but fails to convert the accented characters. I have read the answers here , but this does not address the same problem. What am I doing wrong, and how can I get this to work?

Have you tried:

è:

è

é:

é 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM