why do i have to use mb_convert_encoding($name,'ISO-8859-15','utf-8') to get accented chars to display?

邮差的信 提交于 2020-01-16 11:20:11

问题


the data im working with here is off of a page that uses utf8 encoding

i've set my database and fields to use utf8_general_ci

now for whatever reason, i have to use the following code on the variable in order to have it display accented characters correctly in the database:

mb_convert_encoding($name,'ISO-8859-15','utf-8');

this makes no sense to me. why do i have to convert it to ISO-8859-15 when phpmyadmin is in utf8, the data is in utf8, and the database and table fields are in utf8?


回答1:


You most likely have not set your database connection to UTF-8, so your database expects you to send ISO-8859 encoded data. See http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html



来源:https://stackoverflow.com/questions/8045118/why-do-i-have-to-use-mb-convert-encodingname-iso-8859-15-utf-8-to-get-acc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!