force unicode strings

Paul Boddie paul at boddie.org.uk
Wed Aug 1 18:56:23 EDT 2007


Stefan Behnel wrote:
>
> I guess you can't afford to wait for Python 3, can you?
>
> http://www.python.org/dev/peps/pep-3100/#atomic-types

No need to: just start python with the -U option:

Python 2.4.1 (#2, Oct  4 2006, 16:53:35)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "æøå"
u'\xe6\xf8\xe5'

It's just like Jython:

Jython 2.1 on java1.5.0_03 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> "æøå"
'\xE6\xF8\xE5'

That's a Unicode object, really. Various IronPython users have pointed
out similar things, too, but this kind of thing has been going on for
about ten years, I guess.

Paul




More information about the Python-list mailing list