Replace accented chars with unaccented ones
Noah
noah at noah.org
Wed Mar 17 14:14:49 EST 2004
Josiah Carlson <jcarlson at nospam.uci.edu> wrote in message news:<c37ugc$llq$1 at news.service.uci.edu>...
> > r += xlate[ord(i)]
> > r += i
>
> Perhaps I'm going to have to create a signature and drop information
> about this in every post to c.l.py, but repeated string additions are
> slow as hell for any reasonably large lengthed string. It is much
> faster to place characters into a list and ''.join() them.
True. Is this better?
... body of latin1_to_ascii() ...
r = []
for i in unicrap:
if xlate.has_key(ord(i)):
r.append (xlate[ord(i)])
elif ord(i) >= 0x80:
pass
else:
r.append (i)
return ''.join(r)
Yours,
Noah
More information about the Python-list
mailing list