mercredi 5 août 2015

HttpURLConnection getResponseMessage() language and codification


I am writing an android library, which uses HttpURLConnection for implementing a REST client. When the getResponseMessage() is called, a string with the error code and response message is returned. The problem I cannot resolve is that this message is returned in Spanish using a codification other than UTF-8. AFAIK, everything in the computer is configured to use English, OS X, Android Studio, etc. Does anyone know how to change this to English and UTF-8? Thanks in advance.

Edit:

1) Android minimum API level 15, target 22.

2) My main problem is with the language, not with codification. If I understood right, Strings in Java are always internally in UTF-16 and I change to UTF-8 when needed. Sorry.

3) When debugging, only the error code member variable (errorResponse) of the HttpURLConnection instance has a value (405), and the instance error message variable member (errorMessage) seems empty.

4) My computer has region Spain, and primary language English (US). The phone is in English. Default locale before getting the response message is "en_US".



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire