What is the best character encoding for Japanese for displaying DB, php and html?

I just want to learn about Japanese language translation, 1) What is the best encoding for mysql database 2) What / how can I print this on an HTML page.? thanks in advance.

+4
source share
4 answers

UTF-8, no doubt. Do everything UTF-8. To put text on UTF-8 on your web page, use it in your HEAD tag:

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

As for MySQL, put the following in 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 get garbage characters from a database from queries made by your application, you may need to complete these two queries before getting Japanese text:

 SET NAMES utf8 SET CHARACTER SET utf8 
+9
source

Make sure

  • The 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 talks about encoding, you can live happily ever after :)

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

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

For HTML

 <meta http-equiv="Content-type" value="text/html; charset=UTF-8" /> 
+5
source

Refresh ... This Q & A suggests that CHARACTER SET utf8mb4 COLLATION utf8mb4_unicode_520_ci best suited for newer versions of MySQL.

+1
source

I would definitely refer to the now multi-canonical PHP UTF-8 Cheatsheet

0
source

Source: https://habr.com/ru/post/1286766/


All Articles