[TxMt] Python unicode error (was: r8839 (Python)) [reposting]
Alexey Blinov
nilcolor at gmail.com
Mon Jun 2 13:17:58 UTC 2008
Hmm... little test give me that:
------------------------------------
nilcolor$ cat test.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
a = u"æble"
sys.__stdout__.write( a.encode("raw_unicode_escape") + "\n" )
print a
nilcolor$ python test.py
?ble
æble
nilcolor$
-------------------------------------
so... IMO print is better. Isn't it?
Alexey Blinov
On Mon, Jun 2, 2008 at 2:24 AM, Hans-Jörg Bibiko <bibiko at eva.mpg.de> wrote:
> Hi,
>
> sorry for breaking the rules! I lost the thread.
>
>>> On 6 Feb 2008, at 22:26, Alexander John Ross wrote:
>>>
>>>> • Add Unicode support to PyMate / ScriptMate.
>>>>
>>>> Changed:
>>>> U trunk/Bundles/Python.tmbundle/Support/PyMate/pymate.rb
>>>> U trunk/Bundles/Python.tmbundle/Support/PyMate/tmhooks.py
>>>> U trunk/Support/lib/scriptmate.rb
>>>
>>>
>>> I got this ticket http://macromates.com/ticket/show?ticket_id=502C2FDD
>>> and after some experiments I think the problem is that PyMate does not
>>> pick up on the encoding provided by the user.
>>>
>>> For example a script like this will error:
>>>
>>> # coding: utf-8
>>> print("æble")
>
>
>
> I do not know whether this helps to solve the problem, but I just figured
> out that 'print' is the problem. If I'm using 'sys.__stdout__.write' instead
> it works.
>
> #!/usr/bin/env python
> # encoding: utf-8
>
> import sys
> import os
>
> a = u"æble"
> sys.__stdout__.write( a.encode("raw_unicode_escape") )
>
> Cheers,
>
> --Hans
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>
More information about the textmate
mailing list