String supports Unicode case mappings

24 Mar 2017 | category: ruby-2.4.0 | Comments
#ruby #tech

String/Symbol#upcase/downcase/swapcase/capitalize(!) now handle Unicode case mappings instead of only ASCII case mappings


  # Before 2.4.0

  irb(main):001:0> 'Türkiye'.upcase
  => "TüRKIYE"
  irb(main):002:0>

  # In 2.4.0

  irb(main):001:0> 'Türkiye'.upcase
  => "TÜRKIYE"
  irb(main):002:0>

  # German mapping
  irb(main):004:0> 'ß'.upcase =>
  => "SS"

Many thanks to Martin Dürst for the feature!