Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does internet explorer 9 show weird characters on UTF8 and whitespace content?

I'm currently working on a customer website and stumbled on this strange error, given the HTML:

<p>&nbsp;</p>
<p>
    <span class="indentLeft">
        REDACTED&nbsp;A/S&nbsp;har hovedsæde i Århus (foto).
    </span>
</p>

Internet Explorer 9 will show the following:

IE9 Snippet showing whitespace characters

Now, to begin with I thought it was an encoding issue, except IE7,IE8, firefox, chrome and safari shows it correctly.

So my question really is... is there something new in Internet Explorer 9 that I'm not aware of, some header of some kind that makes it display HTML entities, or is it my server side encoding?

I tried forcibly changing encodings in IE9 with no luck so I'm back to square one.

like image 500
Kristoffer Sall-Storgaard Avatar asked May 04 '11 10:05

Kristoffer Sall-Storgaard


3 Answers

What is the character encoding being used by the file that stores the HTML? Determine the encoding, then set that encoding to be used by whatever parses the document. For example, if your document is stored with the UTF-8 encoding:

<head>
    <meta charset="UTF-8">
</head>

I would also try changing the font, just to make sure it's not a glyph issue, but I suspect encoding as well.

like image 53
Nathan Ryan Avatar answered Oct 13 '22 02:10

Nathan Ryan


I solved the issue by opening the file (theme-ui.php) in visual studio and saving it as "unicode without signature".

like image 35
החלקת שיער Avatar answered Oct 13 '22 00:10

החלקת שיער


I have a similar problem in IE9 where utf-8 delivered by xmlHTTPRequest becomes interpreted as ISO 8859-1 despite the fact that the implementing document contains:

<meta http-equiv="content-type" content="text/html;charset=utf-8">

.. and that XMLHttpRequest.getResponseHeader('Content-Type') returns: text/html; charset=UTF-8

Changing to a non TTF font doesn't help

This happens if the implementing document contains:

<meta http-equiv="X-UA-Compatible" content="IE=8">

The problem goes away if the line is removed or is changed to:

<meta http-equiv="X-UA-Compatible" content="IE=7">
like image 42
Terje Rosenlund Avatar answered Oct 13 '22 00:10

Terje Rosenlund