Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the best character encoding for Japanese language for DB, php, and html display?

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.

like image 891
coderex Avatar asked Dec 06 '22 05:12

coderex


1 Answers

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
like image 179
karim79 Avatar answered Dec 08 '22 14:12

karim79