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

asales

Expert
Licensed User
Longtime User
I have this text file in attached with this names (UTF8):
B4X:
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.
 

Attachments

  • profiles_utf8.txt
    68 bytes · Views: 271

asales

Expert
Licensed User
Longtime 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:
B4X:
j.PostBytes("http://192.168.0.100:8080/InsertProfile", objJSon.ToString.GetBytes("ISO-8859-1"))
 
Upvote 0
Top