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

5
  • 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 stackoverflow.com/q/4350886/4299358 and stackoverflow.com/q/31390545/4299358 Commented Aug 23, 2020 at 11:21
  • Yes, you need to decode the JSON... :) Commented Aug 23, 2020 at 14:48
  • Delphi has its own built in JSON framework, and there are several other 3rd party JSON libraries for Delphi. Commented Aug 23, 2020 at 17:35
  • 2
    And marking your Content-Type as text/html is wrong, too, when in fact you're sending application/json, see stackoverflow.com/q/477816/4299358 Commented Aug 24, 2020 at 1:25
  • Thank you @AmigoJack, I had a bad big mistake Commented Aug 24, 2020 at 4:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.