UTF8 and Japanese characters

前端 未结 4 698
星月不相逢
星月不相逢 2021-01-03 11:31

Problem: Foreign character are not displayed as they should be. This includes German, Japanese, Russian and all others excluding English (works perfectly). Ones PHP makes a

相关标签:
4条回答
  • 2021-01-03 12:04

    See: http://www.w3.org/TR/html4/charset.html#h-5.2.2

    So you should use: <META http-equiv="Content-Type" content="text/html; charset=UTF-8">

    Ideally this info shall be supplied in headers of HTTP response.

    0 讨论(0)
  • 2021-01-03 12:04

    You most likely need to set the character set of your database connection to UTF-8.

    How to do that depends on the database library you are using.

    In the old mySQL library, it would be

    mysql_query("SET NAMES utf8");
    

    (pre mySQL 5.0.7) and

    mysql_set_charset("utf8");
    

    for mySQL 5.0.7 and newer.

    0 讨论(0)
  • 2021-01-03 12:13

    try calling

    mysql_query("SET NAMES utf8");
    

    somewhere before your query. of course if you're on PHP.

    0 讨论(0)
  • 2021-01-03 12:16

    mysql utf-8 is not the real utf-8. it uses 3 bytes instead of 4. For real utf-8, you have to use utf8mb4:

    mysql_query("SET NAMES utf8mb4");
    mysql_set_charset("utf8mb4");
    
    0 讨论(0)
提交回复
热议问题