1 message in org.python.python-bugs-list[ python-Feature Requests-923697 ] SA...
FromSent OnAttachments
SourceForge.netMar 29, 2004 5:21 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[ python-Feature Requests-923697 ] SAX2 'property_encoding' feature not supportedActions...
From:SourceForge.net (nore@sourceforge.net)
Date:Mar 29, 2004 5:21:59 pm
List:org.python.python-bugs-list

Feature Requests item #923697, was opened at 2004-03-26 07:39 Message generated for change (Settings changed) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=923697&group_id=5470

Category: None

Group: None Status: Open Resolution: None Priority: 4 Submitted By: Joseph Walton (josephw) Assigned to: Nobody/Anonymous (nobody) Summary: SAX2 'property_encoding' feature not supported

Initial Comment: I need to parse a byte stream as an XML document and, afterwards, access the same document as a Unicode string. I would prefer to rely on the parser's charset-determining logic, and the 'property_encoding' feature ("http://www.python.org/sax/properties/encoding") seems to offer exactly this information.

However, the default Expat parser doesn't support this feature.

--- from xml.sax import make_parser, handler from xml.sax.xmlreader import InputSource from sys import stdin

p = make_parser()

# Should not fail. Should it return None, or UTF-8? assert(p.getProperty(handler.property_encoding) == None)

source = InputSource() source.setByteStream(stdin)

p.parse(source)

# Should now be the name of the actual encoding used assert(p.getProperty(handler.property_encoding) != None) ---

This raises SAXNotRecognizedException.

Is there another SAX parser I could use instead?

----------------------------------------------------------------------