A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2003-September/201383.html below:

unicode 3 digit decimal conversion

unicode 3 digit decimal conversion unicode 3 digit decimal conversionPeter 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4