javastringunicodeencodingmojibake

How to replace � in a string


I have a string that contains a character � I haven't been able to replace it correctly.

String.replace("�", "");

doesn't work, does anyone know how to remove/replace the � in the string?


Solution

  • That's the Unicode Replacement Character, \uFFFD. (info)

    Something like this should work:

    String strImport = "For some reason my �double quotes� were lost.";
    strImport = strImport.replaceAll("\uFFFD", "\"");