I've found thousands of similar questions over web but none of them with the same problem I've.
I'm using a third party json web api, but the answered json has sometimes special characters that are wrongly printed over HTTP
ex: {"message": "Usu\u00e1rio n\u00e3o encontrado", "status": "fail"}
it shoud be: {"message": "Usuário não encontrado", "status": "fail"}
I've no control on the backend api, and i've tried everything to tell the server to answer me UTF-8
, my request has the headers:
Accept: */*;charset=UTF-8
Accept-Charset: UTF-8
but the server keeps answering wrong characters... So i've tried to read the raw http response and decode it by myself
byte[] temp = resp.errorBody().bytes();
errorResponse = new String(temp);
errorResponse = new String(temp,"UTF-8");
errorResponse = new String(temp,"iso-8859-1");
errorResponse = new String(temp,"US-ASCII");
errorResponse = new String(temp,"windows-1252");
errorResponse = new String(temp,"Windows-1251");
errorResponse = new String(temp,"GB2312");
errorResponse = new String(temp,"ISO-8859-2");
errorResponse = new String(temp,"Windows-1250");
I've debuged this code and checked that new assertion still keeps the wrong characters.
So I believe that the backend server produces an iso-8859-1 String and print it literally on an UTF-8 http body.
Again: I've no control over backend code, is there any way i can fix this string on client side?