开发者

php website not showing correctly in utf-8

开发者 https://www.devze.com 2023-01-08 16:35 出处:网络
I have a website which has some non standard characters such as ë, Ç etc. The website uses ISO-8859-1 as it\'s character encoding, however at this point I want to switch it to UTF-8 for some reason

I have a website which has some non standard characters such as ë, Ç etc.

The website uses ISO-8859-1 as it's character encoding, however at this point I want to switch it to UTF-8 for some reasons related to rss feeds.

When i change the character encoding to utf-8 the mentioned characters are displayed incorrectly.

I set the charse开发者_StackOverflowt through the php header function:

header("Content-Type: text/html; charset=ISO-8859-1");

Any idea as to how to fix this problem ?


header("Content-Type: text/html; charset=ISO-8859-1");

So, are you using ISO-8859-1 or UTF-8? This header is telling the browser "please assume the content of this site is encoded in ISO-8859-1 and interpret it as such." If the content of the site is not actually in this encoding, the result will be gibberish to some extend.

This goes to say that the problem is that what it says on the label is not actually what's in the can.


Never heard about entities ? http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references .

Else, you have to reencode your files (with your editor, you should be able to save your files specifying an encoding).

You can also do it with external programs, like iconv

iconv -f ISO-8859-1 -t utf8 your_file > your_new_file


If you are storing that information in the database, check the database collation, it must be UTF-8 also.

0

精彩评论

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