[New-bugs-announce] [issue14587] Certain diacritical marks can and should be capitalized... e.g. ü --> Ü
Christian Clauss
report at bugs.python.org
Sun Apr 15 16:17:28 CEST 2012
New submission from Christian Clauss <cclauss at bluewin.ch>:
BUGS: certain diacritical marks can and should be capitalized...
str.upper() does not .replace('à', 'À').replace('ä', 'Ä').replace('è', 'È').replace('é', 'É').replace('ö', 'Ö').replace('ü', 'Ü'), etc.
str.lower() does not .replace('À', 'à').replace('Ä', 'ä').replace('È', 'è').replace('É', 'é').replace('Ö', 'ö').replace('Ü', 'ü'), etc.
str.title() has the same problems plus it capitalizes the letter _after_ a diacritic. e.g. 'lüsai'.title() --> 'LÜSai' with a capitol 'S'
myUpper(), myLower(), myTitle() exhibit the correct behavior with a handful of diacritic marks.
def myUpper(inString):
return inString.upper().replace('à', 'À').replace('ä', 'Ä').replace('è', 'È').replace('é', 'É').replace('ö', 'Ö').replace('ü', 'Ü')
def myLower(inString):
return inString.lower().replace('À', 'à').replace('Ä', 'ä').replace('È', 'è').replace('É', 'é').replace('Ö', 'ö').replace('Ü', 'ü')
def myTitle(inString): # WARNING: converts all whitespace to a single space
returnValue = []
for theWord in inString.split():
returnValue.append(myUpper(theWord[:1]) + myLower(theWord[1:]))
return ' '.join(returnValue)
----------
components: Unicode
messages: 158332
nosy: Christian.Clauss, ezio.melotti
priority: normal
severity: normal
status: open
title: Certain diacritical marks can and should be capitalized... e.g. ü --> Ü
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14587>
_______________________________________
More information about the New-bugs-announce
mailing list