A
A
Andrey Samoylenko2020-05-28 00:28:23
Android
Andrey Samoylenko, 2020-05-28 00:28:23

Problem with JSON encoding, Android Studio?

I get JSON from a certain resource, I looked at the html source code, there is no encoding set there. As a result, I get diamonds with a question mark in the application when outputting text from this JSON. Is there some method or way to decode this? I'm trying URLEncoder, but it still doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Yudakov, 2020-05-28
@Ketch

The encoding of the response text is set in the "Content-Type" http header, for example like this:
Content-Type: application/json; charset=utf8
or like this:
Content-Type: text/html; charset=windows-1251


I get JSON from a certain resource, I looked at the html source code, there is no encoding set there.

That's the way it should be.
And don't pay attention to any "meta charset" in the standard. This is just a hint to the browser for difficult cases, when the web server itself does not know in what encoding the text is returned.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question