How to ask sax for the file encoding

Edward K. Ream edreamleo at charter.net
Wed Oct 4 15:40:17 CEST 2006


Following the usual cookbook examples, my app parses an open file as 
follows::



parser = xml.sax.make_parser()

parser.setFeature(xml.sax.handler.feature_external_ges,1)

# Hopefully the content handler can figure out the encoding from the <?xml> 
element.

handler = saxContentHandler(c,inputFileName,silent)

parser.setContentHandler(handler)

parser.parse(theFile)



Can anyone tell me how the content handler can determine the encoding of the 
file?  Can sax provide this info?



Thanks!



Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edreamleo at charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------






More information about the Python-list mailing list