Post UTF-8 encoded data to server loses certain characters

后端 未结 6 1929
旧巷少年郎
旧巷少年郎 2020-12-02 12:31

I am working on project which includes communication of the server (JavaEE app) and client (Android app). XML is sent as one of POST parameters of the HTTP request (named \"

6条回答
  •  悲哀的现实
    2020-12-02 13:03

    After much research and attempts to make things working, I finally found a solution for the problem, that is a simple addition to existing code. Solution was to use parameter "UTF-8" in the UrlEncodedFormEntity class constructor:

    form = new UrlEncodedFormEntity(nameValuePairs,"UTF-8");
    

    After this change, characters were encoded and delivered properly to the server side.

提交回复
热议问题