Feature #10002
closedString swapcase
Added by randy15 (Andreas Runk) over 11 years ago. Updated over 8 years ago.
Description
Hi, the ruby version 2.1.2 has a problem with the .swapcase function and german letters.
E.g. "ä".swapcase
does return "ä" but should be "Ä".
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
Actions
#1
[ruby-core:63476]
- Tracker changed from Bug to Feature
Updated by matz (Yukihiro Matsumoto) over 11 years ago
Actions
#2
[ruby-core:63479]
The current implementation of case conversion methods in String class only understands ASCII characters.
We'd like to enhance it when possible. But we have to know how each character should be converted.
For example, how should we convert "ß" (eszett)?
Matz.
Updated by naruse (Yui NARUSE) over 11 years ago
Actions
#3
[ruby-core:63480]
At this time, ffi-icu or twitter-text-rb is useful.
Updated by davispuh (Dāvis Mosāns) over 11 years ago
Actions
#4
[ruby-core:63481]
It have been already figured out by Unicode Standard, so just have to implement it. Look at Default Case Algorithms in section 3.13 and Case Mappings in section 5.18. Mappings can be viewed in SpecialCasing.txt (and UnicodeData.txt) also CaseFolding.txt could be useful.
From there "ß" (LATIN SMALL LETTER SHARP S) in uppercase would be "SS" (LATIN CAPITAL LETTER S) and it's user's responsibility to know that generally they are not reversible.
Also useful to read Character Properties, Case Mappings & Names FAQ
Updated by zzak (zzak _) over 11 years ago
Actions
#5
[ruby-core:63483]
We should delegate to @emboss everytime we need to convert ß...
Updated by shyouhei (Shyouhei Urabe) over 11 years ago
Actions
#6
[ruby-core:63517]
We are talking about swapcase, not folding. The "generally they are not reversible" you say is the difficulty we are facing here. Also as you cited CaseFolding.txt, you should have been aware of type T folding, which is impossible without locale information.
If you think you can implement it, please show us.
Dāvis Mosāns wrote:
It have been already figured out by Unicode Standard, so just have to implement it. Look at Default Case Algorithms in section 3.13 and Case Mappings in section 5.18. Mappings can be viewed in SpecialCasing.txt (and UnicodeData.txt) also CaseFolding.txt could be useful.
From there "ß" (LATIN SMALL LETTER SHARP S) in uppercase would be "SS" (LATIN CAPITAL LETTER S) and it's user's responsibility to know that generally they are not reversible.
Also useful to read Character Properties, Case Mappings & Names FAQ
Updated by duerst (Martin Dürst) about 11 years ago
Actions
#7
[ruby-core:63970]
- Related to Feature #10085: Add non-ASCII case conversion to String#upcase/downcase/swapcase/capitalize added
Updated by duerst (Martin Dürst) over 8 years ago
Actions
#8
[ruby-core:81773]
- Status changed from Open to Closed
This has actually been implemented by Feature #10085, so it can be closed.