Is there a function to remove escape characters from a string ?

John Machin sjmachin at lexicon.net
Fri Dec 26 18:39:46 EST 2008


On Dec 27, 12:05 am, Stef Mientki <stef.mien... at gmail.com> wrote:

> Yep, chr(254), because it's not in the human range of characters
> and it's accepted by windows ini-files.

>>> import unicodedata as ucd
>>> for i in (0,1,2,3,4,7,8):
...    s = chr(254)
...    enc = 'cp125' + str(i)
...    try:
...       u = s.decode(enc)
...    except UnicodeDecodeError:
...       continue
...    print enc, 'U+%04X' % ord(u), ucd.name(u)
...
cp1250 U+0163 LATIN SMALL LETTER T WITH CEDILLA
cp1251 U+044E CYRILLIC SMALL LETTER YU
cp1252 U+00FE LATIN SMALL LETTER THORN
cp1253 U+03CE GREEK SMALL LETTER OMEGA WITH TONOS
cp1254 U+015F LATIN SMALL LETTER S WITH CEDILLA
cp1257 U+017E LATIN SMALL LETTER Z WITH CARON
cp1258 U+20AB DONG SIGN

Either you have a strange and narrow definition of "human", or you are
so brave as to cheerfully insult (inter alia) Romanians, Russians,
Icelanders, Greeks, Turks, Czechs, Estonians, Finns, Slovaks,
Slovenians, and Vietnamese :-)



More information about the Python-list mailing list