Can upper() or lower() ever change the length of a string?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon May 24 08:13:59 EDT 2010


Do unicode.lower() or unicode.upper() ever change the length of the 
string?

The Unicode standard allows for case conversions that change length, e.g. 
sharp-S in German should convert to SS:

http://unicode.org/faq/casemap_charprop.html#6

but I see that Python doesn't do that:

>>> s = "Paßstraße"
>>> s.upper()
'PAßSTRAßE'


The more I think about this, the more I think that upper/lower/title case 
conversions should change length (at least sometimes) and if Python 
doesn't do so, that's a bug. Any thoughts?


-- 
Steven



More information about the Python-list mailing list