> Another possibility is to open the file in binary mode and do the
> encoding yourself when writing text. This might actually be a better
> solution, since I'm not sure RTF uses utf-8 by default.
Yes, thanks for this suggestion, it seems the best to me. Actually RTF
is not UTF-8 encoded, it's 8
Antoine Pitrou, 25.04.2010 02:16:
Another possibility is to open the file in binary mode and do the
encoding yourself when writing text. This might actually be a better
solution, since I'm not sure RTF uses utf-8 by default.
That's a lot cleaner as it doesn't use two interfaces to write to the
Hello,
> I have to read the contents of a binary file (a PNG file exactly), and
> dump it into an RTF file.
>
> The RTF-file has been opened with codecs.open in utf-8 mode.
You should use the built-in open() function. codecs.open() is outdated in
Python 3.
> As I expected, the utf-8 decoder c
Thanks, I'll try this.
> I have no idea how you'd go about reading the contents of such a file
> in a sensible way.
The purpose is to embed PNG pictures in an RTF file that will be read
by OpenOffice. It seems that OpenOffice reads RTF in 8-bit, so it
should be ok.
The RTF is produced from a TeX
On Fri, Apr 23, 2010 at 9:48 AM, Chris Rebert wrote:
> On Fri, Apr 23, 2010 at 9:22 AM, wrote:
>> I have to read the contents of a binary file (a PNG file exactly), and
>> dump it into an RTF file.
>> how can I tell python to dump the bytes as they are, without
>> interpreting them?
>
> Go arou
On Fri, Apr 23, 2010 at 9:22 AM, wrote:
> I have to read the contents of a binary file (a PNG file exactly), and
> dump it into an RTF file.
>
> The RTF-file has been opened with codecs.open in utf-8 mode.
>
> As I expected, the utf-8 decoder
You mean encoder.
> chokes on some combinations of b
Hello.
I have to read the contents of a binary file (a PNG file exactly), and
dump it into an RTF file.
The RTF-file has been opened with codecs.open in utf-8 mode.
As I expected, the utf-8 decoder chokes on some combinations of bits;
how can I tell python to dump the bytes as they are, without