DECODE GREEK CHARACTERS IN JSON PHP

Brad Pitt

Total Post:61

Points:429
Posted by  Brad Pitt
JSON 
 2077  View(s)
Ratings:
Rate this:
Hi Expert,

I have an XML document that contains greek characters and works perfectly. When I convert it to JSON using PHP the greek characters are being encoded.

      {"id":"101","name":"\u0398\u0397\u039a\u0395\u03a3 \u0397\/\u03a5"}

What I do is: Write xml to a file and then read the file and convert it to JSON

      $handle = fopen("xml_cat.xml","w+");
      fwrite($handle, $xml);
      $sxml = simplexml_load_file('xml_cat.xml');
      echo json_encode($sxml);


How can I get greek characters back?

Any help on above is really appreciated.
  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Decode Greek characters in JSON PHP

    Hi Brad,


    Any client which can properly decode the JSON format will get the original characters back. "\uXXXX" is a perfectly valid transport encoding for arbitrary characters in the JSON format. You don't need to do anything special, you just need to decode the JSON properly; something you're doing anyway when working with JSON. 



Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!