Ruby 1.9 - invalid multibyte char (US-ASCII)
Write # encoding: utf-8
on top of that file. That changes the default encoding of all string/regexp literals in that file utf-8
. The default encoding for all literals is US-ASCII
, which cannot represent á
.
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: