Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to determine the encoding of a xml-file?

0 views
Skip to first unread message

Winston

unread,
Nov 29, 2002, 8:31:55 AM11/29/02
to
Hi Group,
my WSH-script (JScript) loads an existing XML-file with MSXML4. This
XML-file has no encoding specified in the prologue. Is there a way to
determine with JScript the encoding of the XML?

Thx,
Winston


Martin Honnen

unread,
Nov 29, 2002, 8:40:32 AM11/29/02
to

An XML parser has to recogize UTF-8 and UTF-16, other encodings have to
be specified in the XML declaration

Winston

unread,
Nov 29, 2002, 9:01:37 AM11/29/02
to
So there's no way with MSXML to determine whether the XML was saved with
e.g. "windows-1252" unless it's specified in the prologue?

Steps to recreate my problem:
- I have a XML-file with some unknown encoding (i guess it's ANSI)
- After loading, MSXML apparently uses UTF-8 for internal handling
- I add node-text to the DOM with some special characters (e.g. german
umlauts)
- MSXML doesn't moan because the special characters fit into UTF-8
- I save the file using the save-method. MSXML saves the file in it's
original encoding (that means apparently in ANSI) and not in UTF-8
- As a result I have a XML-file with special characters in it that don't fit
into the encoding of the file.
- When I open the XML with the Internet Explorer I get a parsing error due
to the invalid characters :-(

Unfortunately I can't simply add an encoding to the prologue because the XML
is dynamically delivered by a third party.
Is there a way to solve my problem?

Winston


"Martin Honnen" <Martin...@t-online.de> wrote in message
news:3DE76E50...@t-online.de...

0 new messages