0

Note: This is not a duplicate of the related question, since it does not answer/solve my problem: How to display UTF-8 characters in phpMyAdmin?


I have a database containing Unicode characters, including Japanese and Arabic. These characters are not displayed correctly in the phpMyAdmin GUI in the browser (via http://localhost/phpmyadmin/) and they appear as mojibake, e.g. カズ.

On the other hand, when connecting to the database and retrieving data from it using PHP PDO, the Unicode characters are all shown correctly, even without setting SET NAMES 'utf8' or adding charset=utf8 in new PDO(…).


Here is everything I have tried so far after extensive research, but without success:

I have already set the collation of the database/tables to utf8mb4_unicode_520_ci before creating the tables and checked the collation again via “Operations” → “Table options” → “Collation”.

I have also tried executing ALTER TABLE xxx CONVERT TO CHARACTER SET utf8mb4; on the tables in question to ensure the character set is correct, however, this does not seem to solve the in-browser issue.

When creating the tables, I made sure to use DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci, but this still does not fix the incorrect encoding.

I even checked the <meta> tag through the web inspector, and it is correctly set to charset="utf-8".

In config.inc.php, I set DefaultCharset to 'utf8mb4' and in my.ini, I included collation-server=utf8_unicode_ci and character-set-server=utf8 under [mysqld] as well as default-character-set=utf8 under [client], which too does not make any difference.

Also, I set “Server connection collation” on the front page of the phpMyAdmin GUI to utf8_unicode_520_ci to match the collation of the tables.

Taking this into consideration, I conclude that the character set/collation of the table is most likely not the problem in itself.


I know I could fix the incorrectly encoded strings by executing the SQL commands from the PHP script or the using mb_convert_encoding($str, "Windows-1252", "UTF-8") (which yields Japanese カズ for $str = "カズ"), but this would be quite time-consuming compared to executing the commands in-browser.


Why are Unicode strings not shown correctly in the GUI and how can I solve this issue? Strings show perfectly fine running the PHP script (which is why this question is not code-specific).

Lypyrhythm
  • 324
  • 2
  • 13
  • 1
    See Mojibake in https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored Do not use any PHP conversion functions; that will just confuse things more. – Rick James Jul 26 '22 at 22:53
  • @RickJames Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/246806/rick-james-lypyrhythm). – Lypyrhythm Jul 27 '22 at 08:06

0 Answers0