Conversation
I have to send UTF-8 strings via Json (e.g., for Umlauts) and need the encoding in the StringEntity! (1) Maybe this also has to be applied to PutRequest (2) Maybe the encoding should also be added to the header.
| { | ||
| try{ | ||
| stringEntity = new StringEntity(json); | ||
| stringEntity = new StringEntity(json, encoding); |
There was a problem hiding this comment.
Is this variable defined anywhere? Seems like it might be missing?
There was a problem hiding this comment.
Sorry for the late answer, I'm not much on github.
encoding is a class member variable and set in the constructor.
If one uses addData(String key, String value), then the added value will be encoded using this class member variable encoding during send() (in line 100). However, if one sets the json directly using addData(String json), the string will be added to the request without using encoding (line 117). In my own code, I therefore added the encoding directly when setting stringEntity. Otherwise, any UTF-8 characters (like umlauts) won't be sent correctly. Alternatively, you can apply the encoding in send() as well. Without this fix, the class advertises to use an encoding which is not actually used everywhere.
I have to send UTF-8 strings via Json (e.g., for Umlauts) and need the encoding in the StringEntity!
(1) Maybe this also has to be applied to PutRequest
(2) Maybe the encoding should also be added to the header.