1st becomes 1 when I enter json

3

When I enter in JSON with codeigniter, when I convert it into string it will 1\u00aa .

$t[0]["teste"] = "1ª";
$data[0]["algo"] = $t;
    
asked by anonymous 26.06.2017 / 23:40

1 answer

2

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"
    
27.06.2017 / 00:03