Which is the best character encoding for Japanese

2020-01-29 07:38发布

i just want to know about the language transation for the Japanese, 1) Which is the best encoding for the database mysql 2) Which/how can i print that in HTML page. ? thanks in advance.

4条回答
Summer. ? 凉城
2楼-- · 2020-01-29 07:44

Update... This Q&A suggests that CHARACTER SET utf8mb4 COLLATION utf8mb4_unicode_520_ci is best in newer versions of MySQL.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2020-01-29 08:01

Make Sure

  1. Database is in UTF8
  2. Database Table is in UTF 8
  3. Output Headers are in UTF 8
  4. HTML Meta Tag is in UTF 8

When everything is talking the encoding you can live happily :)

For MySQL: utf8 charset, utf8_general_ci collation For PHP headers:

header('Content-type: text/html; charset=UTF-8') ;

For HTML

<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />
查看更多
干净又极端
4楼-- · 2020-01-29 08:01

I'd definitely refer to the now-somewhat-canonical PHP UTF-8 Cheatsheet

查看更多
劳资没心,怎么记你
5楼-- · 2020-01-29 08:08

UTF-8 without a doubt. Make everything UTF-8. To put UTF-8 encoded text on your web page, use this within your HEAD tag:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

As for MySQL, put 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 you're getting garbage characters from the database from queries executed by your application, you might need to execute these two queries before fetching your Japanese text:

SET NAMES utf8
SET CHARACTER SET utf8
查看更多
登录 后发表回答