Jump to content

Unicode characters displayed incorrectly

Recommended Posts

No matter what I try, unicode characters that are read from a MySQL database like japanese ones are replaced by "?" while characters like "ä", "ö", "ü", "»", "«", etc. are replaced by "�".

I pasted this at the top of the PHP code:

header('Content-Type: text/html; charset=UTF-8');


I saved the PHP file as UTF-8 and UTF-8 without BOM and put <meta charset="UTF-8"> into it. (When I insert unicode characters directly in the file, they're displayed correctly, though...)

I set the encoding in the phpMyAdmin database table to different "UTF-8" encodings. (They're displayed correctly too when viewed in the table directly...)

Nothing worked so far.


Any ideas?

Edited by Squarepusher
Link to post
Share on other sites

I set "collation connection", "collation server" and "collation database" to "utf8_general_ci" and "character set server", "character set results", "character set filesystem", "character set database", "character set connection" and "character set client" to "utf8" but it still doesn't help.

Link to post
Share on other sites

You need to change the actual connection, between your PHP script and MySQL.  You do that in your PHP code.  e.g.:

$pdo = new PDO(    
        array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...