Re: Re: Internet Explorer doesn't display UTF-8 page using UTF-8 encoding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



IE doesn't actually support XHTML, so if your primary target for something is IE, you really shouldn't be using XHTML. Even IE7 doesn't fully support it.

Setting the charset in the response header like you did is the best approach. You can do it for all your pages in your php.ini file with:

default_charset = "UTF-8"

If you want to do it in your page contents, it needs to look like this:

<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">

Your attempt with the xml header would have worked if IE knew what the heck XHTML was.

By the way, everyone should be setting a charset. If you don't set it, IE will look at the first 4k of the body of the page and take a wild guess. If it guesses wrong, typically because someone injected UTF-7 into your page, then you have an XSS on your hands.

-Rasmus

Jonny Bergström wrote:
It's me again. I might have solved it... in a way. Still quite puzzled about
why IE don't give a dime about the meta encoding line in the html head tag.

Here's what I did. The aforementioned header file now adds a header()
statement sending a content-type that also tells the charset, utf-8. :

---snip---
<?php
header('Content-Type: text/html; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html>
   <head>
       <meta name="Content-type" content="text/html; charset=UTF-8" />

---snip---


I don't know if it's the best way to solve it but IE seems happy with it,
and I haven't seen any sideeffects in FF so far.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux