Android Question [solved] JSON encoding

Similar threads

Games [XUI2D] Example Pack
B4A Code Snippet [B4X] GUID
B4A Tutorial Integrating Firebase Services
B4A Tutorial Text files
B4A Tutorial [B4X] OkHttpUtils2 with Wait For

emexes

Well-Known Member
Licensed User
What happens if you change the IIS/ASP setting to:

response.Charset = "WTF-2019"

Does IIS give any errors or warnings?

Does it display correctly in a browser?

Does it work in B4A with j.GetString2("ISO-8859-1")?

Does it work in B4A with j.GetString2("UTF-8)?

<JOKE>I wanted to suggest trying response.Charset = "TRUMP-2020" but I didn't want to blow up the forum</JOKE> ;-)
 

Erel

Administrator
Staff member
Licensed User
The server is misconfigured. It sets the content encoding to UTF-8 but the text isn't really encoded with UTF-8:



You can see that Firefox doesn't display the characters correctly.
 

emexes

Well-Known Member
Licensed User
Yes. See #9.
No. this is the same as j.getstring as B4A is using utf8 by default.
Sorry, I should have directed those questions to the original poster. But I'm glad to receive some answers, even though it's put you above and beyond the call of duty, so: thank you :)

My current assessment, assuming that you set up your local IIS with CharSet = "WTF-2019" or something equally invalid, is that IIS seems to be outputting ISO-8859-1 / windows-1250 regardless of CharSet setting.

In which case Albrecht may as well direct his efforts away from making IIS output UTF-8, and on to less-impossible goals.

:)
 

emexes

Well-Known Member
Licensed User
It sets the content encoding to UTF-8 but the text isn't really encoded with UTF-8
Agreed. Great minds think alike. Well, at least one great mind, and the other's, like, throwing darts blindfolded ;-)

edit: Heck, I though that was a DonManfred post. The above holds true for both, though.
 
Last edited:

emexes

Well-Known Member
Licensed User
with that kind of settings before the creation of the Json :
response.ContentType = "application/json"
response.Charset = "UTF-8"
Hey Albrecht, I know I said I was over this, but... I am no good at leaving threads unpulled.

If you still *really* need to use UTF-8, then try using these two settings together:
B4X:
response.CodePage = 65001
response.Charset = "UTF-8"
and then see if the data is encoded and sent using UTF-8, and correctly decoded by:
B4X:
Dim WorksLikeMagic As String = Job.GetString2("UTF-8")
and thus perhaps even by:
B4X:
Dim WorksLikeMagic As String = Job.GetString
 

ALBRECHT

Active Member
Licensed User
Yesssss,

Thank you very much emexes.

I ve just add the response.CodePage setting to : 65001

I add some chars like : ßñɶϕ

I set : Job.GetString2("UTF-8")

and now its a real UTF-8 with th listview !

Thank you very much.
 

ALBRECHT

Active Member
Licensed User
please, sould i make someting to close that post or its automaticaly closed or set as resolved ... ?
 

DonManfred

Expert
Licensed User
On the upper right (maybe on page 1) you can find THREAD TOOLS. Edit the threadtitle and prefix the thread with "[solved]"
 
Top