开发者

PHP & mySQL - ë written as ë [duplicate]

This question already has answers here: 开发者_开发百科 Closed 11 years ago.

Possible Duplicate:

PHP messing with HTML Charset Encoding

We've come across special characters being transformed.

What is causing this? How can we fix it?

For example:

ë becomes ë

Thank you.


Thats a utf-8 character and you can parse it through utf8_encode() and utf8_decode() in PHP


Charset can be set at numerous places.

  • table charset
  • field charset
  • PHP-MySQL connection charset
  • Apache default charset
  • and in HTML metainfo

Make sure you use UTF-8 everywhere, and don't forget to setup the connection properly before the first query:

mysql_query("SET NAMES 'utf8'");


Make sure you are setting your charset in HTML document and with PHP header's function.

Also, you could try to make the first query in MySQL to be SET NAMES=UTF8 (SET NAMES utf8 in MySQL?)


If this is the output of a PHP script, I guess you may consider mb_internal_encoding() function.

Or you can fix that by HTML encoding meta tag. Like <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> inside <head>...</head>.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜