jsonunicodeutf-8arabic

displaying arabic character with JSON


i'm trying to create an arabic json file using php, but the problem is that i'm getting weird characters instead of the usual arabic letters (ابو ميزان).

i'm using mysql_query("SET NAMES 'utf8'");

i have tried to find a solution to the problem but i'm stuck i have tested to output the string on a php file and it is working, and arabic letters are displaying, and the json string is as i want it.

but whenever i put the json header, header('Content-type: application/json'); i'm getting the weird characters

can anyone help could this be related to my php (5.1.6) version


Solution

  • Set header in this way:-

    header( 'Content-Type: application/json; charset=utf-8' );