471,123 Members | 844 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

encoding type for existing .xml doc

How to determine the encoding type for an existing .xml doc ? UTF8 , 1252 ,
etc.
Aug 4 '06 #1
2 903
John A Grandy:
How to determine the encoding type for an existing .xml doc ?
UTF8 , 1252 , etc.
mainly guess! ;-)

What's needed:

http://groups.google.com/groups?thre...%40tkmsftngp04

For UTF-8 and UTF-16 see

http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8

.... especially the part on BOM.

Mark
Aug 5 '06 #2


John A Grandy wrote:
How to determine the encoding type for an existing .xml doc ? UTF8 , 1252 ,
etc.
If the encoding is anything but UTF-8 or UTF-16 then the XML document
should have an XML declaration at the beginning declaring the encoding e.g.
<?xml version="1.0" encoding="Windows-1252"?>
Of course it is allowed to use the XML declaration for UTF-8 or UTF-16
too but if it is not there the XML parser is supposed to detect it using
the presence/absence of a fitting BOM, see
<http://www.w3.org/TR/REC-xml/#charencodingfor details.

Whether it is XML or HTML or some other text it is in general not
possible to determine the encoding of a document without there being
some declaration (e.g. XML declaration in XML, <metaelement in HTML)
or external information (e.g. HTTP Content-Type header with charset
parameter) that describes the encoding.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Klaus Alexander Seistrup | last post: by
30 posts views Thread by aurora | last post: by
reply views Thread by David Bolen | last post: by
2 posts views Thread by Brajesh Jain | last post: by
4 posts views Thread by fitsch | last post: by
2 posts views Thread by jmhmaine | last post: by
15 posts views Thread by John Salerno | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.