Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: httpwebwitch
The problem is that no matter what I try, HTML entities such as the non-breaking space   are displayed properly in the browser, but in the source code, they are munged and appear as ┬.
This wouldn't matter except Google also sees these munged source characters, causing our Google listings to look like garbage.
If I look at the source code in Firefox, it's fine. It's only a problem when viewed through Internet Explorer, Opera or Google.
Why is this and how do I solve it?
Here's an example input XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="no" method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
And here's the output source, copied from Internet Explorer View Source:
Anybody seen this and what did you do?
as a non-breaking space and printing the literal character rather than keeping the entity reference. However, you have an underlying encoding problem: the document seems to be UTF-16 not UTF-8 - the
is a giveaway as if you read a (two-byte) UTF-16 document in a non-UTF-16-aware user agent (Opera, IE, Google, but not Firefox) then the
represents the first byte of the two-byte character.
Are you able to define the output charset? If so, it needs to be ISO-8859-1 or (better) UTF-8.
What is baffling me though is why Google, Opera etc seem to be seeing my files as UTF-16 when they are clearly UTF-8 encoded - I'm sending UFT-8 Content-Type headers, I have UTF-8 declared in the XML and XSL templates, I have saved all my files in UTF-8 format. And yet they still seem to be coming out the other end as UTF-16.
I am at no point using ASP.NET strings - just an XslTransform and XmlDocuments.
I even see the BOM (Byte Order Mark) at the start of my file, as shown below:
´╗┐<?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><body>
Totally baffled - any advice much appreciated.