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:
JavaScript
x
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
Advertisement
Answer
I am consuming the REST api, so while getting the output I have to maintain UTF-8 encoding.
JavaScript
BufferedReader br = new BufferedReader(new InputStreamReader((inputStream), standardCharsets.UTF_8));
I have added standardCharsets.UTF_8