unicode 3 digit decimal conversion
Peter Otten
__peter__ at web.de
Sat Sep 27 07:07:20 EDT 2003
Rune Hansen wrote:
> >>> unicode("Gratis øl","iso-8859-1")
> u'Gratis \xf8l'
> >>>ord("\xf8")
> 248
>
> What I need is the converted string to read u'Gratis \248l' (*
> How do I do this without going through each and every character of the
> string?
> (not that I have figgured out how to do that right either)
I see your problem is already solved, just want to add that normally (read:
C and Python) the backslash notation is base 8 not base 10.
>>> ord("\248")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: ord() expected a character, but string of length 2 found
>>> oct(248)
'0370'
>>> ord("\370")
248
>>>
Peter
More information about the Python-list
mailing list