[TxMt] Python unicode error (was: r8839 (Python)) [reposting]
Hans-Joerg Bibiko
bibiko at eva.mpg.de
Mon Jun 2 13:45:47 UTC 2008
On 2 Jun 2008, at 15:40, Allan Odgaard wrote:
> On 2 Jun 2008, at 15:34, Allan Odgaard wrote:
>
>> [...]
>> To work with UTF-8 strings written to stdout in Python you need to:
>>
>> 1. Declare the source code to be UTF-8 (done with the encoding
>> comment).
>> 2. Declare the string itself to be a unicode string (done with the
>> u-prefix).
>> 3. Set the output stream to be UTF-8 (done by wrapping stdout in a
>> codec-aware writer).
>>
>> If step 3 is omitted, the encoding of stdout will be taken from the
>> environment, so often it will still work.
>> [...]
>
> I should have added that this is actually desired, i.e. to have
> Python convert the output to whatever encoding the environment is
> using.
>
> Most users though does not have LC_CTYPE properly setup (but they
> should fix that!).
>
> In Leopard Terminal will set LANG automatically. Unfortunately
> sometimes it is set to an invalid value (<rdar://5564288>) and IMO
> they should only set LC_CTYPE.
The process of learning will never become to an end (fortunately) ;)
Thanks a lot!!
--Hans
More information about the textmate
mailing list