开发者

UTF-8 string wrongly encoded somewhere

开发者 https://www.devze.com 2023-02-07 05:04 出处:网络
I have a column, title, which is of the format CHAR(50) utf_genral_ci. I have a php script that successfully inserts a new row with the title value \"Bjørn\".

I have a column, title, which is of the format CHAR(50) utf_genral_ci. I have a php script that successfully inserts a new row with the title value "Bjørn".

The problem occurs when I want to pull it out again. Once it is assigned to a variable the string is开发者_如何转开发 "Bjørn".

Some have pointed me towards mb_*(), however since it's not a problem when I am retrieving it from a form and inserting it, but only when I retrieve it from mysql, I dont believe that can be it.

I have made sure that it is in fact encoded correctly in mysql, and server, database, table, column and connection are ALL UTF-8.

Please someone save me from this nightmare!

Thanks in advance


It turned out to be because I used the php function htmlentities() on my string. Very weird since last I tried, it also output wrong straight from the database.

I have been having problems with this all day, so the solution to one problem has caused another.

Thanks for taking your time.


Did you check the value in database using an admin tool like phpMyAdmin or MySQL Workbench? If it is not displayed correctly, try converting the name to utf-8 using iconv ($in_charset, 'utf-8', $str). If it is correct, make sure that the encoding in your browser is set to UTF-8.

0

精彩评论

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