Timothée HENRY
Timothée HENRY

Reputation: 14604

Mysql utf32_unicode_ci and html charset utf-8 used, but character � appear

I have some text in French in a MySQL field, which appears correctly under PHPMyAdmin:

mentionné

The field is encoded as utf32_unicode_ci. (It is a varchar(500), utf32_unicode_ci).

but a call to a PHP script calling this parameter and outputing in html encoded in utf-8 returns:

mentionn�

Here is an extract of my php html header:

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="fr-FR">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

How can I fix this?

Upvotes: 3

Views: 899

Answers (1)

Sebas
Sebas

Reputation: 21532

Please, besides the database encoding, be sure you check the following:

  • utf8 encoding of the FILES (js/php) (under ultra-edit, F12: save as UTF8-NOBOM)
  • utf8 html content: <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
  • utf8 of your db connection: SET character_set_connection = 'utf8'
  • utf8 of your query results: SET character_set_results = 'utf8'
  • utf8 of your db client: SET character_set_client = 'utf8'
  • utf8 of your mysql tables: ALTER TABLE table CONVERT TO CHARACTER SET utf8;
  • utf8 of your db server: SET character_set_database = 'utf8' and SET character_set_server = 'utf8'
  • in some cases, forcing utf8 in file is necessary when hardcoded values need encoding. You would need to add a comment on top of your file for instance, with charset=utf-8, so ultra edit or your favorite editor can detect it.

rgds.

ps: I don't know utf32 but somehow the logic should be the same

Upvotes: 2

Related Questions