[ACCEPTED]-Which is the best character encoding for Japanese language for DB, php, and html display?-character-encoding
UTF-8 without a doubt. Make everything UTF-8. To 7 put UTF-8 encoded text on your web page, use 6 this within your HEAD tag:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
As for MySQL, put 5 the following into your my.cnf (config) file:
[mysqld]
collation_server=utf8_unicode_ci
character_set_server=utf8
default-character-set=utf8
default-collation=utf8_general_ci
collation-server=utf8_general_ci
If 4 you're getting garbage characters from the 3 database from queries executed by your application, you 2 might need to execute these two queries 1 before fetching your Japanese text:
SET NAMES utf8
SET CHARACTER SET utf8
Make Sure
- Database is in UTF8
- Database Table is in UTF 8
- Output Headers are in UTF 8
- HTML Meta Tag is in UTF 8
When everything is talking the 3 encoding you can live happily :)
For MySQL: utf8 2 charset, utf8_general_ci collation For PHP 1 headers:
header('Content-type: text/html; charset=UTF-8') ;
For HTML
<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />
Update... This Q&A suggests that CHARACTER SET utf8mb4 COLLATION utf8mb4_unicode_520_ci
is best in newer versions 1 of MySQL.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.