We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon 3.0 json utf8 render

Hello, After I have updated Phalcon from 2.0.10 to Phalcon 3.0 (with PHP 7.0.9) my endpoints dosent support utf8 chars (special Sweedish characters) when rendering :

{"status":"success","http_code":200,"data":[{"id":1,"name":"SOME NAME","slug":"some-name"},{"id":2,"name":"SOME & NA\u00c4DG\u00c5ME","slug":"some-name"},{"id":3,"name":"SOME & NAME","slug":"some-name"} ...

Codes like : \u00c4DG\u00c5 , \u00c4 ... So im getting an errorors at enpoints that retrives data with json ..


#1 [internal function]: Phalcon\Mvc\View-&gt;render('cars', 'brends', Array)<br />
#2 /var/www/project-core/public/index.php(67): Phalcon\Mvc\Application-&gt;handle()<br />
#3 /var/www/project-core/public/index.php(73): Application-&gt;main()<br />
#4 {main}

Any1 have problems like this?

Aditional info: When I vardump() my query results from db, characters are well writen with UTF8 (same line in my DB with Sweedish special characters). So problem is encoding it json. Im using Fractal Transformers

edited Aug '16

That should be valid JSON, non-ASCII chars are escaped automatically unless you force it with a flag to unescape. When you load it back to an object or array with json_decode, you'll get regular chars in Sverige.



23.6k
Accepted
answer

That should be valid JSON, non-ASCII chars are escaped automatically unless you force it with a flag to unescape. When you load it back to an object or array with json_decode, you'll get regular chars in Sverige.

Yep, Iv got it... this should be normal for raw JSON .. Now I have to take care of this errors uner ...



23.6k

When I downgrade phalcon to 2.0.13 there is no more errors. I saw that there was same prbolem when 2.0 came out.. They need to fix it.

error: The argument is not initialized or iterable()