[Python-Dev] Unicode howto in the works - feedback appreciated
Gustavo Niemeyer
niemeyer@conectiva.com
Wed, 1 May 2002 04:19:49 -0300
Hi Skip!
> I began working on a Unicode HOWTO a few weeks ago, got a little ways on it,
> then ignored it until this morning. I added a little bit more to it then
> decided I should get some feedback. You can view it at
[...]
> Consider it a start. Feedback welcome.
Thanks for the initiative!
Something which should probably be added is about this issue:
>>> s = "Marc-André".decode('iso-8859-1')
>>> print s
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeError: ASCII encoding error: ordinal not in range(128)
I'm not sure if this is a common issue with other languages. But at
least here (brazilian portuguese), this is a little bit inconvenient.
Fortunately, fixing this is easy, since site.py was nicely prepared
for this (thanks <author> ;-):
if 0:
# Enable to support locale aware default string encodings.
import locale
loc = locale.getdefaultlocale()
if loc[1]:
encoding = loc[1]
Enabling it should be enough:
>>> s = "Marc-André".decode('iso-8859-1')
>>> print s
Marc-André
(Marc-André, sorry for taking your name as an example ;-)
--
Gustavo Niemeyer
[ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]