1

I have a PHP application that calculate all my data and return answers to HTML page with AJAX and JQuery. in top of my PHP code I add

 header("Content-Type: text/html; charset=utf-8");

and return data with

echo json_encode($returndata);

and also i save my file with UTF-8 Format all things work good with HTML but when i get PHP response with a another program for example Delphi IDHTTP then arabic character show like :\u06f2 \u0634\u0647\u0631\u06cc\u0648\u0631 \u06f1\u06f3\u06f9\u06f9 \u06f1\u06f4:\u06f1\u06f3

in this picture you can see response that i catch from IE i run PHP on server with IIS here is my Delphi application here is my Delphi code

try

RespJson := IdHTTP1.Post
  ('http://192.168.0.6:1000/allcalculate.php',data);
finally
data.Free;
end;
delete(RespJson,length(RespJson),1);
delete(RespJson,1,1);
RespJson := StripChars(RespJson,['"']);
arrresp:= splitstring(RespJson,',');
arrresp:=splitstring(arrresp[30],':');
advedit48.Text:=arrresp[1];

how can i fix this problem thank you and sorry for bad english

F.Kahalaj
  • 86
  • 8
  • 5
    Well, you perform `json_encode()` in PHP but haven't considered looking for something like `json_decode()` in Delphi? Because character encodings like `\u06f2` are totally legal in JSON. See https://stackoverflow.com/q/4350886/4299358 and https://stackoverflow.com/q/31390545/4299358 – AmigoJack Aug 23 '20 at 11:21
  • Yes, you need to decode the JSON... :) – Arnaud Bouchez Aug 23 '20 at 14:48
  • Delphi has its own [built in JSON framework](http://docwiki.embarcadero.com/RADStudio/en/JSON), and there are several other 3rd party JSON libraries for Delphi. – Remy Lebeau Aug 23 '20 at 17:35
  • 2
    And marking your **Content-Type** as `text/html` is wrong, too, when in fact you're sending `application/json`, see https://stackoverflow.com/q/477816/4299358 – AmigoJack Aug 24 '20 at 01:25
  • Thank you @AmigoJack, I had a bad big mistake – F.Kahalaj Aug 24 '20 at 04:01

0 Answers0