On my server, the database is encode in utf8mb4_unicode_ci
I'm writing an API to serve data in JSON.
The PHP function json_encode only accepts utf8.
I'm not able to build the full chain:
strings encoded in utf8mb4_unicode_ci => utf8 => json => API => JavaScript => strings encoded in utf8mb4_unicode_ci
For example, $str = "Linéaire ";
From utf8mb4_unicode_ci to utf8 I already try the PHP functions utf8_encode(str) and
mb_convert_encoding($str, 'UTF-8', 'Windows-1252') that return respectively:
"Lin\u00c3\u00a9aire \u00f0\u009f\u0098\u0080""Lin\u00c3\u00a9aire \u00f0\u0178\u02dc\u20ac"
Both functions do not return the same result. I don't know which one to choose. Furthermore, I don't know how to unescape the string on client side in JavaScript.