New submission from Matthew Barnett <pyt...@mrabarnett.plus.com>: I've found that the following 4 Unicode characters/codepoints don't behave as I'd expect: Dž (U+01C5), Lj (U+01C8), Nj (U+01CB), Dz (U+01F2).
For example, u'\u01C5'.istitle() returns True and unicodedata.category(u'\u01C5') returns 'Lt', but u'\u01C5'.title() returns u'\u01C4' (DŽ), which is the uppercase equivalent. I believe that these 4 codepoints are the only ones where the titlecase differs from uppercase. I thought it might be a mistake in the Unicode database. However John Machin says: Doesn't look like it. AFAICT it's a mistake in Objects/unicodetype.c, function _PyUnicode_ToTitlecase. See http://svn.python.org/view/python/trunk/Objects/unicodectype.c?rev=66362&view=markup The code that says: if (ctype->title) delta = ctype->title; else delta = ctype->upper; should IMHO merely be: delta = ctype->title; A value of zero for ctype->title should be interpreted simply as the offset to add to the ordinal, as it is in the sibling _PyUnicode_To (Upper|Lower)case functions. See also Tools/unicode/makeunicodedata.py which treats upper, lower and title identically when preparing the tables used by those 3 functions. AFAICT making that change will fix the problem for those four characters and not ruin any others. The error that you noticed occurs as far back as I've looked (2.1) and also occurs in 3.0. ---------- components: Unicode messages: 80020 nosy: mrabarnett severity: normal status: open title: Incorrect title case type: behavior versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4971> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com