appy.gen: bugfixes.

This commit is contained in:
Gaetan Delannay 2012-05-08 14:49:45 +02:00
parent 6245023365
commit 8cc20b0d34
5 changed files with 24 additions and 13 deletions

View file

@ -281,23 +281,20 @@ def cleanXhtml(s, keepStyles=False):
return s
# ------------------------------------------------------------------------------
toLower = {'Ç':'ç','Ù':'ù','Û':'û','Ü':'ü','Î':'î','Ï':'ï','Ô':'ô','Ö':'ö',
'É':'é','È':'è','Ê':'ê','Ë':'ë','À':'à','Â':'â','Ä':'ä'}
toUpper = {'ç':'Ç','ù':'Ù','û':'Û','ü':'Ü','î':'Î','ï':'Ï','ô':'Ô','ö':'Ö',
'é':'É','è':'È','ê':'Ê','ë':'Ë','à':'À','â':'Â','ä':'Ä'}
def lower(s):
'''French-accents-aware variant of string.lower.'''
isUnicode = isinstance(s, unicode)
if not isUnicode: s = s.decode('utf-8')
res = s.lower()
for upp, low in toLower.iteritems():
if upp in res: res = res.replace(upp, low)
if not isUnicode: res = res.encode('utf-8')
return res
def upper(s):
'''French-accents-aware variant of string.upper.'''
isUnicode = isinstance(s, unicode)
if not isUnicode: s = s.decode('utf-8')
res = s.upper()
for low, upp in toUpper.iteritems():
if low in res: res = res.replace(low, upp)
if not isUnicode: res = res.encode('utf-8')
return res
# ------------------------------------------------------------------------------