0

I have been reading for the last two days about this. Most posts seem to be a bit old. (seem to predate the utf8mb4 encoding in Mysql) At this point I can insert Japanese characters from a webpage using php. When I retrieve the data it is displayed correctly in the webpage but not in phpmyadmin.

I can also insert Japanese characters into the database using phpmyadmin and then they are displayed correctly in phpmyadmin but not on the webpage if I retrieve the same data.

I added this to my.cnf file

[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4

SHOW VARIABLES LIKE 'char%' gives me

Variable_name   Value
character_set_client    utf8
character_set_connection    utf8mb4
character_set_database  utf8mb4
character_set_filesystem    binary
character_set_results   utf8
character_set_server    utf8mb4
character_set_system    utf8
character_sets_dir          /usr/share/mysql/charsets/

SHOW VARIABLES LIKE 'collation%'

Variable_name   Value
collation_connection    utf8mb4_unicode_ci
collation_database  utf8mb4_unicode_ci
collation_server    utf8mb4_unicode_ci

How can I change the character_set_client, character_set_results and character_set_system from utf8 to utf8mb4 and will this enable me to input Japanese that will be displayed correctly on the webpage using phpmyadmin ?

On a side note is the html appropriate or is there some charset that is closer to UTF8MB4 ?

thank you

anatak
  • 440
  • 2
  • 7
  • 16
  • What MySQL API are you using in PHP? See [Connection Character Sets and Collations](http://dev.mysql.com/doc/en/charset-connection.html) and [UTF-8 all the way through](http://stackoverflow.com/a/279279). – eggyal Jan 10 '14 at 00:39
  • thank you eggyal, I did not find that post the link (UTF-8 all the way through) was excellent and now everything works. – anatak Jan 11 '14 at 07:35

1 Answers1

1

You should check if the HTML document has the same encoding that you have set in character_set_client and character_set_result (utf8). If you have string literals in japanese, then the file containing the HTML must be encoded with the same charset, too.

Max Oriola
  • 1,296
  • 12
  • 8