diff --git a/intl/unicharutil/tools/gencasetable.pl b/intl/unicharutil/tools/gencasetable.pl index c95d118fac1..f48a3e71b78 100644 --- a/intl/unicharutil/tools/gencasetable.pl +++ b/intl/unicharutil/tools/gencasetable.pl @@ -36,6 +36,14 @@ # # ***** END LICENSE BLOCK ***** +# If you run this script because the Unicode standard has been updated, +# check xpcom/string/public/nsCharTraits.h to see whether +# nsCharTraits::ASCIIToLower needs to be updated. It only +# needs to be update if the Unicode consortium adds (or removes) +# a Unicode character whose lowercase form is an ASCII character. +# Currently there are only two such characters: KELVIN SIGN and +# LATIN CAPITAL LETTER I WITH DOT ABOVE. + ###################################################################### # # Initial global variable diff --git a/xpcom/string/public/nsCharTraits.h b/xpcom/string/public/nsCharTraits.h index d5d2ce6b992..e7713c9520f 100644 --- a/xpcom/string/public/nsCharTraits.h +++ b/xpcom/string/public/nsCharTraits.h @@ -234,13 +234,27 @@ struct nsCharTraits } /** - * Convert c to its lower-case form, but only if c is ASCII. + * Convert c to its lower-case form, but only if the lower-case form is + * ASCII. Otherwise leave it alone. + * + * There are only two non-ASCII Unicode characters whose lowercase + * equivalents are ASCII: KELVIN SIGN and LATIN CAPITAL LETTER I WITH + * DOT ABOVE. So it's a simple matter to handle those explicitly. */ static char_type ASCIIToLower( char_type c ) { - return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; + if (c < 0x100) + return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c; + else + { + if (c == 0x212A) // KELVIN SIGN + return 'k'; + if (c == 0x0130) // LATIN CAPITAL LETTER I WITH DOT ABOVE + return 'i'; + return c; + } } static