fredrik at pythonware.com
Tue Jun 26 10:13:23 EDT 2001
Johan Daine wrote:
> I am using using swish++ with Zope in a french context.
> In orger to filter the user requests, I need to filter accented
> characters to the unaccented char.
assuming you have 2.0 or later, something like this
import unicodedata, string
# build iso-latin-1 to "undotted" ascii translation table
table = range(256)
for i in table:
x = unicodedata.decomposition(unichr(i))
if x and x == "0":
table[i] = int(x.split(), 16)
return string.join(map(chr, table), "")
text = "...some accented iso-latin-1 text..."
noaccents = maketable()
undotted_text = string.translate(text, noaccents)
hope this helps!
<!-- (the eff-bot guide to) the python standard library:
More information about the Python-list