This question already has an answer here:
- UTF-8 all the way through 14 answers
I have some code with FluentPDO with UTF-8 encoding like this: http://pastebin.com/KGKFBbVC and result: http://i.imgur.com/WaAJ0b9.png but when i run this, it is not working, my database using utf8_general_ci collation. I try to edit and search this problem on this page but it still does not working. Please help me
do you serve the data to the endpoint with explicit UTF-8 encoding too? You need to ensure your database, your database connection, your PHP file, the resulting data stream, AND the end point, all know to use UTF8.
That means the db needs to use utf8 typing and collation (fun fact: if you're using MySQL or MariaDB, you need the
utf8mb4... ones, not the older
utf8... ones. Hurray for not-future-compatible encoding choices), your php files need to be saved in utf8 encoding (BOM optional, kind of discouraged, in fact), your connection to the database should specify it wants to use charset/names in utf8, and the resulting stream is utf-8 encoded so if you're generating a webpage with it, the HTTP header needs to specify it's sending UTF8 data (or not specify the content encoding), and the HTML source needs a
<meta charset="utf-8"> element in the
There's quite a few places where you're switching contexts, and each of that places need to be told to force UTF8.