开发者

∞ gets converted to ∞ when inserted into MySQL table

The infinity () symbol gets converted to ∞ when it is inserted into my MySQL table by a PHP script, but if I insert it directly from 开发者_开发技巧phpMyAdmin, it inserts correctly. The symbol is passed to the PHP script by a GET call with the JavaScript function encodeURIComponent() around the contents. The field in the MySQL database is utf8_swedish_cl. How do I get to insert as into the database?


Check this real good SO answer: UTF-8 all the way through…


Are you sure that phpMyAdmin is doing it right? ∞ Looks a lot like a UTF8 character stored in a latin-1 column.

What do you get when you do this select hex(column_name) from the_table?

  • If it's E2889E, then your connection is UTF8, your column may not be.

  • If it's C3AC, then your connection is latin-1 and your column is utf8.

  • If it's EC, then both your connection and column are latin-1

Here's a quick way to verify that the column's encoding is UTF8:

select 
    column_name, character_set_name, collation_name 
from 
    information_schema.columns
where
    table_name = '_your table_'


Are you setting SET NAMES utf8 before inserting the content into the database?


Don't forget the "query" SET CHARACTER SET utf8 at the beginning of your scripts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜