Re: Proper use of the codecs module.

2013-08-16 Thread Chris Angelico
On Fri, Aug 16, 2013 at 3:02 PM, Andrew wrote: > I have a mixed binary/text file[0], and the text portions use a radically > nonstandard character set. I want to read them easily given information > about the character encoding and an offset for the beginning of a string. To add to all the inform

Re: Proper use of the codecs module.

2013-08-16 Thread Andrew
On 16 Aug 2013 19:12:02 GMT, Steven D'Aprano wrote: > If you try opening the file in text mode, you'll very likely break the > binary parts (e.g. converting the two bytes 0x0D0A to a single byte > 0x0A). So best to stick to binary only, extract the "text" portions of > the file, then explicitly

Re: Proper use of the codecs module.

2013-08-16 Thread Steven D'Aprano
On Fri, 16 Aug 2013 10:02:08 -0400, Andrew wrote: > I have a mixed binary/text file[0], and the text portions use a > radically nonstandard character set. I want to read them easily given > information about the character encoding and an offset for the beginning > of a string. "Mixed binary/text"

Proper use of the codecs module.

2013-08-16 Thread Andrew
I have a mixed binary/text file[0], and the text portions use a radically nonstandard character set. I want to read them easily given information about the character encoding and an offset for the beginning of a string. The descriptions of the codecs module and codecs.register() in particular see