Re: [xsl] Re: Problem with encoding using document function

Subject: Re: [xsl] Re: Problem with encoding using document function
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 2 Mar 2005 12:58:16 GMT
  aDocXml.createProcessingInstruction("xml", " version='1.0'
  encoding='ISO-8859-1'")


the <?xml syntax is not a processing instruction, it's an xml
declaration. It tells a parser some things (mainly the encoding) that it
needs to interpret the bytes in the file as unicode characters. once the
thing is parsed into a tree it's not really in an encoding at all in
that sense it is a data structure that contains characters, not a string
of bytes that encode uniocde according to some encoding. (Of course
really it's all just 1's and 0's in memory so everything is an encoding
really but that is working at a different level.

So if your xsml document has already been processed enough to generate
an aDocXml object the system must already have figured out what encoding
the original file was in, so the above, even if it worked, would not
have any effect.


> I've attached the string containing the instruction to the beginig of the XML.
> response.Write "<?xml version=""1.0"" encoding=""ISO-8859-1"" ?>" & aDocXml.xml

that looks dangerous. The rest of the file will be linearised according
to the object's .xml method in whatever encoding that uses (mst likely
utf8 or utf16 I'd have thought) but you are unconditionally appending a
declaration that the file is in latin1. Note that if the file is in utf8
but you say it's latin1 you won't get an error, you just get spurious
characters which is why people often complain about getting accented A
appearing before no breaking space; it's what you get if you interpret
a utf8 byte stream as latin 1.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread