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

Stef Mientki stef.mientki at gmail.com
Fri Dec 26 19:41:40 EST 2008


John Machin wrote:
> 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 :-)
>   
Sorry if I offended someone, that was certainly not my intention.
And I guess you will be surprised, if I tell you, I don't (want) to 
understand any bit of the above code ;-)
Come on, the home computer was invented about 1980.
If we look at hardware, it follows the Moore's law,
for software I would expect at least 0.1 of Moore's law ;-)
I hope that clarifies my point.

cheers,
Stef




More information about the Python-list mailing list