Project

General

Profile

Feature #19317

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

As announced in [Case Mapping](https://docs.ruby-lang.org/en/master/case_mapping_rdoc.html#label-Default+Case+Mapping), Ruby support for Unicode case mapping is not complete yet. 

 Unicode supports in Ruby is pretty awesome, it works by default nearly everywhere, things are implemented the right way and works as expected by the UTRs. 

 But some features are still missing. 

 To reach [ICU Full Case Mapping support](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#full-language-specific-case-mapping), a few points need to be enhanced. 

 ### context-sensitive case mapping 

 * [ ] cf. [Table 3-17 (Context Specification for Casing) of the Unicode standard](https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf) and [ucd/SpecialCasing.txt](https://www.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt). 

 ```ruby 
 "ΣΣ".downcase # returns σσ instead of σς 
 ``` 

 Output examples in ECMAScript: EMCAScript: 

 ``` 
 Σ      ➡️ σ 
 Σa     ➡️ σa 
 aΣ     ➡️ aς 
 aΣa    ➡️ aσa 
 ΣA     ➡️ σa 
 aΣ a ➡️ aς a 
 Σ1     ➡️ σ1 
 aΣ1    ➡️ aς1 
 ΣΣ     ➡️ σς 
 ``` 

 ## language-sensitive case mapping 

 * [ ] Lithuanian rules 
 * [x] Turkish and Azeri 

 ```ruby 
 "I".downcase # => "i" 
 "I".downcase(:turkic) # => "ı" 
 "I\u0307".upcase # => "İ" 
 "I\u0307".upcase(:lithuanian) # => "İ" instead of "I" 
 ``` 

 * [ ] using some standard locale / language codes 

 Also, it's true that for now there are only a few language-sensitive rules (for Lithuanian, Turkish and Azeri) but why:  

 - adding a `:turkic` symbol and not a `:azeri`? 
 - using full english arbitrary (why `turkic` and not `turkish`?) language name rather than some [ICU locale IDs](https://unicode-org.github.io/icu/userguide/locale/)? 
   - Language code ISO-639 standard 
   - Script code Unicode ISO 15924 Registry 
   - country code ISO-3166 standard 

 So I would rather see something like that 

 ```ruby 
 "placeholder".upcase(locale: :tr_TR) 
 "placeholder".upcase(lang: :tr) 
 ``` 

Back