Non Latin Characters & ouch

后端 未结 2 1123
予麋鹿
予麋鹿 2021-01-07 05:33

I\'m getting to know Cake PHP, which has unearthed a general question about best practice in terms of PHP / MySQL character set stuff, which I\'m hoping can be answered here

相关标签:
2条回答
  • 2021-01-07 06:02

    That question comes here often.

    UTF8 should work. Make sure that:

    1. Your database collation uses utf8 (utf8 bin general)

    2. You html document encoding tag is set to utf8

    3. AND VERY IMPORTANT - most people forget that bit - make sure all your source files are saved as utf8. Use notepad++ on pc or Coda/TextMate/TextWrangler on mac to make sure the encoding is correct. If you don't do that, some transformation/re-interpretation of the characters may happen

    EDIT: And forget about htmlentities, you don't need it if you use utf8 encoding all throughout

    0 讨论(0)
  • 2021-01-07 06:10

    Make sure the MySQL connection is set to UTF-8 while importing the data. The collation is only used for sorting and comparison, not for saving data.

    You can set the charset of the connection using SET NAMES 'utf-8'; in the beginning of your SQL file.

    0 讨论(0)
提交回复
热议问题