Ruby 1.9 - invalid multibyte char (US-ASCII)

后端 未结 3 1284
慢半拍i
慢半拍i 2020-12-12 14:53

Im trying to make my rails application (2.3.5) to run on Ruby 1.9, I\'ve this function that make some transformations on a string:

def replace_special_chars(         


        
3条回答
  •  星月不相逢
    2020-12-12 15:33

    I think you can also change the regexps from the syntax /re/ to the syntax (Regexp.new 're', nil, 'n')

    For example, the instruction you mentioned:

    string.gsub! /á|ã|à|ä|â/, 'a'

    will become:

    string.gsub! (Regexp.new 'á|ã|à|ä|â', nil, 'n'), 'a'

    More details here:

    http://www.ruby-forum.com/topic/183413

提交回复
热议问题