How to ask sax for the file encoding

Edward K. Ream edreamleo at
Wed Oct 4 16:48:19 CEST 2006

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

> there is no encoding on the "inside" of an XML document; it's all Unicode.

True, but sax is reading the file, so sax is producing the unicode, so it 
should (must) be able to determine the encoding.  Furthermore, xml files 
start with lines like:

<?xml version="1.0" encoding="utf-8"?>

so it would seem reasonable for sax to be able to return 'utf-8' somehow. 
Am I missing something?

Edward K. Ream   email:  edreamleo at

More information about the Python-list mailing list