I have a problem in Laravel ..
When I use echo or print_r or var_dump my data (retrieved from eloquent) are printed in the right format (UTF-8, greek language). But when I use " return Response::json($data) "
returns something like:
"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03bf\u03af \u03c7\u03b1\u03c1\u03b1\u03ba\u03c4\u03ae\u03c1\u03b5\u03c2"
I have already set UTF-8 as default charset in my php.ini, mysql.conf (but this is not the problem).
I have tried several ways to set the charset like:
Response::json($data,200,$headers) --> where $headers is an array with:
'Content-type'=> 'application/json; charset=utf-8'
Also tried to add charset inside laravel's response.php but nothing changes...
My operating system is Debian 7 wheezy 64bit, PHP version 5.5.13 , MySQL 5.6.19 and apache2 server.
They are converted characters. There shouldn't be a problem if you decode it or use it in javascript.
gcreator, for a more complete comprehension what's going on
brilliant answers!! Thank you all!!!
I have just changed a little bit the Response::json like:
Response::json($data,200,$headers,JSON_UNESCAPED_UNICODE);
and works like a charm!!!!!!
Thank you!!!!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community