how to convert é,ê,… in database mysql to the normal string é,â,… using php?

丶灬走出姿态 提交于 2019-12-11 14:55:52

问题


There are the problems of data in mysql.

Some data store with the string like (1):"hello & hello ' hello è ...". And some data store with the string like (2):"hello à hello é hello ê ...".

I can solve the string (1) to the normal string, but I don't know how to convert the string (2) to the normal string?

Note : We can not change the data in the existing database :/ Also the both sample is store in the same table and the charset of the table is latin1!


回答1:


hello à hello é hello ê probably is UTF-8 interpreted as ISO-8859-1.

You can either change the interpretation, e.g. in a browser set a charset, or convert it to ISO-8859-1 using utf8_decode().




回答2:


EDIT-

Without changing the DB structure try this --

ini_set('default_charset', 'YOUR_CHARACTER_SET')

OR try this --

header('Content-Type: text/html; charset=iso-8859-1');

Check this setting, its all bcoz of table collation




回答3:


Use CONVERT as CONVERT ("hello à hello é hello ê ...", ascii) ....



来源:https://stackoverflow.com/questions/13004892/how-to-convert-%c3%83-%c3%83%c2%aa-in-database-mysql-to-the-normal-string-%c3%a9-%c3%a2-using-ph

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