Json encoded for characters without ascii?

I know that json_encode requires UTF-8 encoding, and I already use this, but in my attempt to pass a php array to javascript, I can not transfer the data as it is.

I put them for test on the html page with a null template, between the JS tags.

$arrs=array("kağıtşim","üğçöşiö"); echo 'data_labels=json_encode($arrs);'; //The result is ; data_labels=["ka\u00c4\u009f\u00c4\u00b1t\u00c5\u009fim","\u00c3\u00bc\u00c4\u009f\u00c3\u00a7\u00c3\u00b6\u00c5\u009fi\u00c3\u00b6"]; 

There is nothing wrong as I know; UTF-8 file without charset specification - UTF-8 Headers set to UTF-8 There is nothing to do with DB

How can I return this json_encode conversion

+2
json javascript jquery php
Nov 15
source share
1 answer

You do not need to return anything. When the JavaScript parser parses these strings, it automatically converts these escape sequences to the appropriate characters.

+3
Nov 15
source share



All Articles