Trouble with unicode
Charlie Clark
charlie at begeistert.org
Mon May 14 17:43:51 EDT 2001
>Their length?
they look about 3 characters long but are only 1 really, I already have
experience converting Unix characters over.
>
>> >>>> from codecs import lookup
>> >>>> toASCII = lookup( 'ascii' )[0]
>> >>>> toASCII( u'123\555' )
>> >>>> toASCII( u'123\555', 'replace' )
>> >('123?', 4)
>> >
>> >>> from codecs import lookup
>> >>> toASCII = lookup ("ascii")[0]
>> >>> toASCII(u"123\555")
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> UnicodeError: ASCII encoding error: ordinal not in range(128)
>> is as far as I get. ... whether there is a bug in the BeOS
>> version of a
>> module? I don't think I made a typing mistake.
>
>Oops :-) change
>toASCII(u"123\555") to
>toASCII(u"123\555", "replace")
okay it works
>>> toASCII(u"123\555", "replace")
('123?', 4)
>>> text
'\xe4, \xc4, \xf6, \xd6, \xfc, \xdc, \xdf'
>>> toASCII(text, "replace")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)
But I'm no closer, am I? I don't quite understand what the codecs module is
and how it works.
Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
http://www.begeistert.org
More information about the Python-list
mailing list