I have an array, with a lot of characters from languages like Russian. When I try to use json_encode to that array, it returns me null.
However, I have a workaround for that, it is to use:
array_map("utf8_encode", $arr );
On the array and then json_encode for the new array. It works, but it gives me some crazy characters like this:
поÑÑеа ÑигниÑеÑÑмÑÑе но веÐ
Instead of russian letters. I have no idea how to fix it and make it work and return real Russian letters as the output. I have tried using json_encode with JSON_UNESCAPED_UNICODE as second parameter, on main array, but it does not work. I have even set the encoding of the database using:
mysqli_set_charset($db,"utf8");
But even that does not fix it. I am totally out of ideas and I don't know what to do.
Background story is that I input the data of array into html (php to json and than javascript to html) but if I don't use array_map, it returns null. If I use it, I have crazy characters all over my html.
Please if anyone has any ideas, share with me, i have no idea what to do.
EDIT: I have solved my problem. However, I did not use JSON at all. I just packed the data into the string with special spliting code. Than, on the client side, I have used string.split("spliting code") in order to get the parts of the string. It works with any encoding.