Others have mentioned that automatically processing names this way is probably a bad idea, but I think it’s interesting to note that this behaviour is something that is going to change in the next release of Ruby (2.4).

Currently, the Ruby string methods such as upcase, downcase, strip etc. only work on ASCII characters; others are left unchanged. This is the root cause of the issue you are having:

    #Ruby 2.3.1
    "BJÖRK".downcase #=> "bjÖrk"

But in Ruby 2.4.0.preview1 this works as expected (as do the other String methods):

    "BJÖRK".downcase #=> "björk"

Currently, with Rails, you can use mb_chars to achieve the same result:

    "BJÖRK".mb_chars.downcase.to_s #=> "björk"

(I still don’t think you should use this on names though.)


Matt

--
You received this message because you are subscribed to the Google Groups "North 
West Ruby User Group (NWRUG)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
Visit this group at https://groups.google.com/group/nwrug-members.
For more options, visit https://groups.google.com/d/optout.

Reply via email to