I have a field in a MySQL database (utf8_general_ci) that contains a curly (smart?) apostrophe: Owner’s...
This prints fine with no special handling if
For details: json_encode
Example:
echo json_encode($array, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
Using PHP's utf8_encode() before my json_encode() did indeed stop the data from cutting off after the ’ but it also encoded it to \0092 which did not display (control character). When I used MySQL's SET NAMES utf8 before my query, I did not have to use utf8_encode() at all, and my json was encoded correctly with ’ mapping to \u2019, which displays nicely.
Thanks for the link @Pekka, it helped me narrow down the possibilities.