I have a servlet that sends a utf-8 encoded string. I also have a client written using the apache httpcomponents library.
My problem is reading the response in utf-8. Some special characters, such as ñ or ç, are not read correctly. If I test the server with the html page sending the request, the string is correct and UTF-8 encoding without specification.
Some snippets:
Servlet
response.setContentType ("application/json; charset=UTF-8");
PrintWriter out = response.getWriter ();
out.write (string);
Client
entity = response.getEntity ();
entity.getContentEncoding (); //returns null
resultado = EntityUtils.toString (entity, HTTP.UTF_8); //Some characters are wrong
Has anyone had the same problem?
SOLVE: Sorry that the client and server are working correctly. I am writing an Android application and it seems that logcat (where I print messages) does not support utf-8 encoding.