marked-down
marked-down

Reputation: 10428

Webpage outputting question marks in place of unicode characters, despite character sets and collation being correct?

When I fetch a record from my database, where the database, the table, and the row are all set to utf8_unicode_ci, I recieve a question boxed in a diagonal square in place of the correct unicode character; this is despite me also setting the HTML encoding on the page with:

 <meta charset="utf8">

I have a suspicion however it is to do with MySQL/PHP though because when I print_r the output the question marks are still displaying while a manually entered degree symbol (the symbol I should be seeing) works fine.

This SQL query also did nothing:

SET NAMES utf8;

Any ideas? I've checked every end of my setup.

Upvotes: 0

Views: 1453

Answers (1)

sergio
sergio

Reputation: 5260

utf8_unicode_ci is the collation, you need the character set as utf8 as example:

CREATE TABLE someTable DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci;

As adrienne states in their answer here:

make sure that all of the following are true:

  • The DB connection is using UTF-8
  • The DB tables are using UTF-8
  • The individual columns in the DB tables are using UTF-8
  • The data is actually stored properly in the UTF-8 encoding inside the database (often not the case if you've imported from bad sources, or changed table or column collations)
  • The web page is requesting UTF-8
  • Apache is serving UTF-8

Upvotes: 3

Related Questions