Archived Forum Post

Index of archived forum posts

Question:

HTTP quickGetStr with arabic letters as return value

Apr 26 '16 at 12:16

I am trying to get some values back from the Twitter Api. But for some reason I cant receive the correct arabic letters (english works perfectly). I always get e.g.: "u0623u0628u0648 u0646".

I pretty sure need to set the charset or something, but I am really stuck and dont know where to look :-/

I did try to set:

http.put_Utf8(true); vals = http.quickGetStr(getstring);

const char* vals would hold something like "حموي" but receives "u0....."


Answer

I know pushing threads is not good, but... I fear I need your help here :-/


Answer

Looks like JSON strings can encode unicode characters as uXXXX, so I suspect you will need to parse these return values. See https://tools.ietf.org/html/rfc7159#section-8.1

Not sure if Chilkat has any methods to do this, but maybe your language does? For example, PHP has a json_decode function that appears to do the necessary decoding.


Answer

Hi jpbro, thank you for the reply. My program is written in c++. Looks like I'll have to do the parsing work on my own :-/ Did not find anything related to this json-return values via chilkat.

But maybe we can be lucky and Chilkat might provide a json-parsing class in the future? Have seen this kind of requests in the forums ;-)


Answer

The http.quickGetStr is just returning the HTTP response body,which could be HTML, XML, JSON, plain-text, or anything else. It can't, nor shouldn't, try to interpret and change the text that is returned.

If the response is JSON, then you can load it into a JsonObject (or CkJsonObject, depending on your programming language), and it should automatically parse the unicode encoding (uXXXX)