When I enter 1ª
in JSON with codeigniter, when I convert it into string it will 1\u00aa
.
$t[0]["teste"] = "1ª";
$data[0]["algo"] = $t;
When I enter 1ª
in JSON with codeigniter, when I convert it into string it will 1\u00aa
.
$t[0]["teste"] = "1ª";
$data[0]["algo"] = $t;
Normal. PHP uses the \u quatro-dígitos-hex
format to escape special (non-ASCII) characters. This is valid JSON, see json.org
If you really want to avoid escape, you can use the JSON_UNESCAPED_UNICODE
:
php > // com a flag:
php > print(json_encode('ºªáéíóú',JSON_UNESCAPED_UNICODE));
"ºªáéíóú"
php > // sem a flag:
php > print(json_encode('ºªáéíóú'));
"\u00ba\u00aa\u00e1\u00e9\u00ed\u00f3\u00fa"