string conversion latin2 to ascii

Jakub Wilk ubanus at users.sf.net
Wed Nov 28 14:04:25 CET 2007


* Martin Landa <landa.martin at gmail.com>, 2007-11-27:
> I have unicode string (or better say latin2 encoding) containing
> non-ascii characters, e.g.
>
> s = "Ukázka_možnosti_využití_programu_OpenJUMP_v_SOA"
>
> I would like to convert this string to plain ascii (using some lookup
> table for latin2)
>
> to get
>
> -> Ukazka_moznosti_vyuziti_programu_OpenJUMP_v_SOA

You may try python-elinks
<http://freshmeat.net/projects/python-elinks/>:


>>> import elinks
>>> print "Ukázka_mo\236nosti_vyu\236ití_programu_OpenJUMP_v_SOA".decode('Windows-1250').encode('ASCII', 'elinks')
Ukazka_moznosti_vyuziti_programu_OpenJUMP_v_SOA


-- 
Jakub Wilk



More information about the Python-list mailing list