0

I am working on an exiting database. All fields seems to be UTF8

enter image description here

Problem is : when I edit some fields in phpmyadmin: I got these chars

En athlétisme

and selecting ISO-8859-1 works fine

mysql_select_db('myDB');
mysql_set_charset('ISO-8859-1', $con1); 

whereas

mysql_select_db('myDB');
mysql_set_charset('utf8', $con1);   

gives

En athlétisme

Question : How can I make it clean and re-encode it all in UTF8 ?

yarek
  • 11,278
  • 30
  • 120
  • 219
  • 1
    And the letter you wanted to be printed instead of `é` was `é`? In utf8 `é` is encoded as the two byte sequence `C3 A9`. Now if something along the way interpreted that sequence as single-byte latin1 characters it would become `é` (also encoded as `C3 A9` but latin1). When you look into the table contents again via phpmyadmin, do you see `é` or `é`? – VolkerK Feb 25 '16 at 00:27
  • well i have never had such a problem with phpmyadnin, its pages are all using utf8 –  Feb 25 '16 at 00:27
  • Is it possible that an application accessing the database is incorrectly handling character encoding (other than PHPMyAdmin)? – Eric J. Feb 25 '16 at 00:28
  • 2
    Could also be just the output of _your_ script. If it "signals" (e.g. via "Content-type=...;charset=iso-8859-1") the client/browser that the contents is latin1 encoded but actually sends utf8 characters, the client/Browser will show `é` instead of `é`. – VolkerK Feb 25 '16 at 00:30
  • The only safe way to look at the bytes in a table is via `SELECT col, HEX(col) ...`. When you look at it through phpmyadmin (or any other client), the connection may be doing conversions. You have Mojibake because not everything is utf8. – Rick James Mar 01 '16 at 15:16
  • Do not use `mysql_*` interface; change to `mysqli_*` or `PDO`. – Rick James Mar 01 '16 at 15:16

0 Answers0