Re: [xml] Query regardin storing of encoding information
- From: Daniel Veillard <veillard redhat com>
- To: Ashwin <ashwins huawei com>
- Cc: ranjit huawei com, xml gnome org, 'Nagesh' <nageshs huawei com>
- Subject: Re: [xml] Query regardin storing of encoding information
- Date: Wed, 23 Apr 2008 03:57:42 -0400
On Wed, Apr 23, 2008 at 11:28:01AM +0800, Ashwin wrote:
We store the encoding of the document as advertized in the
xml declaration in the document encoding itself.
Breakpoint 1, xmlFreeDoc (cur=0x725d98) at tree.c:1175
1175 xmlFreeDoc(xmlDocPtr cur) {
(gdb) p cur->encoding
$1 = (const xmlChar *) 0x725ed8 "ISO-8859-1"
(gdb)
Hi,
Suppose I am using Sax callbacks for parsing, in that case if I want to
know the encoding specified in the xml declaration, I will try to retrieve
it from ctxt->encoding, however ctxt->encoding is set to only UTF-8 or
UTF-16, depending on whichever is specified in the xml declaration. In case
the xml declaration specifies any other encoding, for instance GB2312, then
ctxt->encoding will be NULL, while ctxt->input->encoding will be set to
GB2312.
My doubt is in the function xmlParseEncodingDecl, ctxt->encoding is not set
to the encoding specified in the xml declaration if its not UTF-8 or
UTF-16...
The function checks if the encoding specified in the xml declaration is
UTF-8 or UTF-16, and sets ctxt->encoding if that is the case else it sets
ctxt->input->encoding to the encoding specified in the xml declaration while
ctxt->encoding is NULL.
Is there any specific reason for this?
Not that I remember. But basically if you use SAX, this means that you're
doing input only of the document, don't plan to save it and hence the
original encoding is not useful.
I don't have any good explanation for not setting ctxt->encoding, this
value is checked in a number of places but I can't think right now why this
would be a problem.
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]