I am using restler PHP API to host a REST service. I am having a problem with handling some European characters, otherwise it is working fine.
For example I have the string “Český rozhlas 1 – Radiožurnál” in a MySQL database. When the restler API converts the data in to JSON, it is converted like this “?esk\u00fd rozhlas 1 – Radio\u009eurn\u00e1l”
Here first character is converted as a question mark.
How can I convert the data properly using the restler PHP service?
When dealing with Unicode, we need to make sure we use utf-8 all the way
First you need to make sure MySQL database is using utf-8 encoding. You can run the following sql to make sure of that
Next you need to make sure MySQL spits utf-8 when talking to PHP.
You can use the following commands
If you are using PDO you need to use the following instead, for connecting to the database
After these changes, restler result should become
Which is valid JSON with complete data where unicode characters are escaped using unicode escape sequences.