Skip to content

special character “” is not work in Linux, converted into “?”

I consuming an api which is returning String with special characters, so I replace them with blank or some other user readable char.

My code:

String text = response;
        if (text != null) {
            text = text.replace("Â", "");
            //same for other special char

The above code works fine for windows machine but in Linux “” converted into “?”, even other all special char converted into “?”. I am using Java, UTF-8 in my HTML. Please let me know any platform independent solution. Thanks



I am consuming the REST api, so while getting the output I have to maintain UTF-8 encoding.

BufferedReader br = new BufferedReader(new InputStreamReader((inputStream), standardCharsets.UTF_8));

I have added standardCharsets.UTF_8

User contributions licensed under: CC BY-SA
2 People found this is helpful