[I18n-sig] Transparent Encoding
Paul Prescod
paulp@ActiveState.com
Fri, 18 May 2001 13:40:37 -0700
"M.-A. Lemburg" wrote:
>
>...
>
> I don't see why you want to make unicode-internal the default
> for data_encoding... if you don't want an encoding, you shouldn't
> use EncodedFile() at all.
What's a better idiom for
stream = codecs.EncodeFile(fileobj, "unicode-internal", "utf-8")
I want to a writable fileobj in a transparent UTF-8 encoder?
----
Also, in Python 2.1 I just noticed that this code does some weird
pointer thing that crashes Python sometimes:
>>> for i in (1,2,3):
... codecs.EncodedFile(open("foo.txt","w"), "unicode-internal",
"utf-8").write(u"\u2222")
...
>>> ^Z
Sometimes it crashes immediately and sometimes it only crashes when you
try to shut down Python. I can submit a bug report if you can't diagnose
this easily and haven't heard of it before.
--
Take a recipe. Leave a recipe.
Python Cookbook! http://www.ActiveState.com/pythoncookbook