Kristoffer Sall-Storgaard Kristoffer Sall-Storgaard - 2 months ago 13
HTML Question

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.

Answer

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.

Comments