Android Question [Solved] Web Service REST and accents (invalid characters) in JSON

Discussion in 'Android Questions' started by asales, Jan 6, 2018.

  1. asales

    asales Well-Known Member Licensed User

    I have this text file in attached with this names (UTF8):
    Code:
    Lúcio Fábio, Sistemas e Soluções, Maria José, Antônio José
    This file is read by a server app that returns JSON to consume in a WebService Rest in my App.

    If connect to a web server using the Chrome browser in my phone, the return is OK (with accents in names):
    web3.jpg
    but If I using my app to connect, I get the invalid characteres in names:
    web4.jpg

    I'm using this example:
    https://www.b4x.com/android/forum/threads/webservice-rest.73466/#post-466819
    and OkHttpUtils2 2.61 library.

    I tried with Download, Download2, Job.GetString, Job.GetString2("UTF8") and StringUtils.DecodeUrl(Job.GetString, "UTF8"), but I don't get the names correctly.

    How can I fix this problem?

    Thanks in advance for any tip.
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    The server response is not encoded in UTF8.

    What is the output of:
    Code:
    Log(Job.GetString2("iso-8859-1"))
     
    asales likes this.
  3. asales

    asales Well-Known Member Licensed User

    Thanks! This was it. The encode is ISO-8859-1.

    Now I use this code to send a map encode with ISO-8859-1, instead PostString, that uses UTF-8 by default:
    Code:
    j.PostBytes("http://192.168.0.100:8080/InsertProfile", objJSon.ToString.GetBytes("ISO-8859-1"))
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice