Archived Forum Post

Index of archived forum posts

Question:

Read received json data as unicode values for arabic/russian language

Jun 20 '17 at 04:50

Hello, I am stuck with a Problem related to json & http requests.

The page I want to read contains json data, which contain arabic or russian text.

In Firefox I can see a view for "json" and a view for "rawdata". Json shows the correct language chars used in arabic or russian. Rawdata shows instead e.g. "u0643"...

I did try:

http.put_AcceptCharset(L"utf-8");

//  Send the HTTP GET and return the content in a string.
const wchar_t *html = 0;
html = http.quickGetStr(L"https://api.access-some-site.org/mytoken/getdata");

MessageBoxW(0,html,L"My Data",0);

It seems to always get the rawdata and this means "u0643", not the char!

Now my question: Is there a way to Access my URL to the json via CkHttpW somehow?


Answer

I think I might need to use CkJsonObjectW to convert text that does not display in language I need.

If I receive like "u0643" which is in fact a german umlaut "Ä" maybe json-class can handle it?

Would I do it like this?

http.put_AcceptCharset(L"utf-8");

// Send the HTTP GET and return the content in a string which is u0643.

const wchar_t *html = 0;

html = http.quickGetStr(L"https://api.access-some-site.org/mytoken/getdata");

//html holds data string like "Hello World! Ä Test" which is "Hello World! u0643 Test"

// place in json object to get back as CStringW?

CkJsonObjectW jsonx;

CStringW output;

jsonx.Load(html);

// output = text in germnan vowel readable

output = jsonx.emit();

MessageBoxW(output,L"testoutput",0);

Buit it still shows up as u0643

:-/