1

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?

Community
  • 1
  • 1
Phil
  • 35,852
  • 23
  • 123
  • 164
  • 2
    It works for me. If I input `èé...'’` it outputs `èé…\'\'`. [Working demo](http://ideone.com/eEfN2J). I think that the issue may be related to the file where you get the name from. Maybe you think you have `è` and `é` but you have similar characters, can you post a sample input? – BackSlash Apr 16 '14 at 21:57
  • 1
    The original file may contain these characters in some encoding, such as UTF-8 or MacRoman, and your Java program expects another encoding. Also possible: the characters may be decomposed into base character plus accent. – Jongware Apr 16 '14 at 22:07

1 Answers1

0

Have you tried:

è:

è

é:

é 
Alsace
  • 73
  • 4