1

With respect to this post: How do I make text-transform:uppercase work properly with Greek? I was wondering what's the proper way to capitalise international strings in Ruby?

Right now for instance a Greek string would return this:

'ένα'.upcase # => ΈΝΑ

This is wrong. Should be 'ENA'. No accents are allowed when all characters are capitalised.

Any ideas?

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
stratis
  • 7,750
  • 13
  • 53
  • 94
  • 5
    `String#upcase` (along with all other basic `String` methods) has no awareness of `locale`. That behaviour isn't "plain wrong"; it's incorrect specifically in the Greek language. I'm not sure how best to handle this, but my inclination is to use [`I18n.transliterate`](https://apidock.com/rails/ActiveSupport/Inflector/transliterate) to handle locale-specific mappings of non-ASCII characters. – Tom Lord Jan 22 '20 at 12:04
  • Aha... I see...This seems a perfectly valid workaround I didn't know of. Thanks. Still though it'd be awesome if there was a builtin locale-aware version of `upcase`... – stratis Jan 22 '20 at 12:19
  • 5
    From the Unicode Standard 12: "Examples of case tailorings which are not covered by data in SpecialCasing.txt include: • Titlecasing of IJ at the start of words in Dutch • Removal of accents when uppercasing letters in Greek (...) The preferred mechanism for defining tailored casing operations is the Unicode Common Locale Data Repository (CLDR), where tailorings such as these can be specified on a perlanguage basis, as needed." (Chapter 3.13) – steenslag Jan 22 '20 at 12:55

0 Answers0