This is not a wxPython problem per se, but it is a critical problem I
have in a wxPython application, so I hope you’ll humor me. I hope
I’m missing something basic; I’m prepared to be embarrassed.
I have literally thousands of flat files which contain “extended
ASCII” (ord = 128 to 255 inclusive) characters. I can read
them all, but I can’t seem to write them, as the typical error I get is
“UnicodeEncodeError: ‘ascii’ codec can’t decode character u’\xdb’ in
position 4: ordinal not in range(128)”.
I simply need to write to disk the exact ordinal values, all between 0
and 255 inclusive, as is. E.g., a byte with value hex DB (decimal
219) needs to be written to disk as the byte hex DB.
How do I avoid codec issues? There’s no codec out there (that I
know of) that will allow ordinal values 0 through 255 to be written
“as is.”
Since I can’t write these files, I’m surprised I can read them. I’m
using the built-in open for both reading and writing.
I’m using wxPython 2.8.4 Unicode with Python 2.5.1 under Windows XP
SP2.
Bob