0

I have some code with FluentPDO with UTF-8 encoding like this: http://pastebin.com/KGKFBbVC and result: https://i.stack.imgur.com/oLRMk.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

2 Answers2

1

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 <head>.

There's quite a few places where you're switching contexts, and each of that places need to be told to force UTF8.

Mike 'Pomax' Kamermans
  • 49,297
  • 16
  • 112
  • 153
0

Most likely your web server is emitting an HTTP header setting Content-Type to ISO-8859-1, which overrules any HTML meta tags you're setting. Set your HTTP headers in PHP and/or convince your web server to do otherwise.

deceze
  • 510,633
  • 85
  • 743
  • 889