Whether I use TIdHTTP or tfphttpclient post method to request specific URL, the non-English character in the response always display hex unicode like
\u8a8d\u8b49
. Do I miss doing something? or How can I convert these to normal unicode string? Any help is going to be appreciated.
My environment: Windows7 64bit, FPC 3.0.4, Lazarus 2.0.0 x86_64 , indylaz 10.6.2
The code with Indy:
// ...
RequestBody := TStringStream.Create(ReqBody);
IdHTTP1.Request.ContentType := 'application/json';
IdHTTP1.Request.CharSet := 'utf-8';
Try
ResponseBody := IdHTTP1.Post(url, RequestBody, IndyTextEncoding_UTF8);
Memo1.Lines.Add(ResponseBody);
finally
RequestBody.Free;
end;
The code with tfphttpclient :
//...
http:= tfphttpclient.Create(nil);
RequestBody := TStringStream.Create(strbody);
try
http.AllowRedirect := true;
http.AddHeader('User-Agent','Mozilla 5.0 (compatible ct)');
http.AddHeader('Content-Type','application/json;charset=UTF-8');
http.RequestBody := RequestBody;
Memo1.Lines.Add(http.Post(url));
finally
http.Free;
RequestBody.Free;
end;