You will indeed need to convert any non-utf8 data into utf8 before passing it to json_encode.
So, with all of my database models I'll need to convert with something like this?
$row->$key = mb_detect_encoding($value, mb_detect_order(), true) === 'UTF-8' ? $value : utf8_encode($value);
Doesn't this seem like it goes against the simplicity of Eloquent? It just seems like there must be a better solution.
I've come across this bug, so I'll be using a wrapper function for all JSON responses that does this:
Response::json(array('text' => ' test'), 200, null, JSON_UNESCAPED_UNICODE);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community