You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By design, str::to_lowercase and str::to_uppercase do not depend on the language of the text (which shouldn’t be assumed to be the same as the locale of the machine running the program).
Mostly, this means ignoring the conditional mappings in Unicode’s SpecialCasing.txt, with one exception: the greek letter Sigma is Σ in upper-case and σ in lower-case except in word-final position, where it is ς. The corresponding mapping in SpecialCasing.txt is:
# <code>; <lower>; <title>; <upper>; (<condition_list>;)? # <comment>
03A3; 03C2; 03A3; 03A3; Final_Sigma; # GREEK CAPITAL LETTER SIGMA
C is preceded by a sequence consisting of a cased letter and then zero or more case-ignorable characters, and C is not followed by a sequence consisting of zero or more case-ignorable characters and then a cased letter.
(cased letter and other terms have a precise definition given beforehand.)
Since char::to_lowercase doesn’t know context, I think it should just return σ for Σ. But str::to_lowercase does have context and could implement this conditional mapping.
… where is_cased_ignorable and is_cased_letter would be private functions based on tables generated by src/etc/unicode.py, according to the definitions in the linked PDF.
In other words: since there is only one such mapping, I think it makes more sense to hard-code it than to try and generalize rustc_unicode::tables::conversions::to_lowercase_table to include arbitrary conditions.
Activity
SimonSapin commentedon Jun 5, 2015
CC @aturon, @alexcrichton
alexcrichton commentedon Jun 5, 2015
Our current trend of conventions and such leads me to think that we should do the special behavior in
str::to_lowercase.SimonSapin commentedon Jun 5, 2015
Untested first attempt:
… where
is_cased_ignorableandis_cased_letterwould be private functions based on tables generated bysrc/etc/unicode.py, according to the definitions in the linked PDF.SimonSapin commentedon Jun 5, 2015
In other words: since there is only one such mapping, I think it makes more sense to hard-code it than to try and generalize
rustc_unicode::tables::conversions::to_lowercase_tableto include arbitrary conditions.SimonSapin commentedon Jun 5, 2015
According to a Greek speaker, not doing this is "Very, very bad. Basically, bad enough that people won’t use it.".
Correctly map upper-case Sigma to lower-case in word-final position. Fix
Remove `to_uppercase` and `to_lowercase`