How to convert a string to lower or upper case in Ruby

后端 未结 11 935
梦如初夏
梦如初夏 2020-12-07 07:00

How do I take a string and convert it to lower or upper case in Ruby?

11条回答
  •  独厮守ぢ
    2020-12-07 07:07

    Like @endeR mentioned, if internationalization is a concern, the unicode_utils gem is more than adequate.

    $ gem install unicode_utils
    $ irb
    > require 'unicode_utils'
    => true
    > UnicodeUtils.downcase("FEN BİLİMLERİ", :tr)
    => "fen bilimleri"
    

    String manipulations in Ruby 2.4 are now unicode-sensitive.

提交回复
热议问题