I am trying to run a rails (2.3.5) application on Ruby 1.9, I have this function that does some conversions in a string:
def replace_special_chars(downcase = true) if downcase string = self.downcase else string = self end string.gsub! /á|ã|à|ä|â/, 'a' string.gsub! /é|è|ë|ê/, 'e' string.gsub! /í|ì|ï|î/, 'i' string.gsub! /ó|õ|ò|ô|ö/, 'o' string.gsub! /ú|ù|ü|û/, 'u' string.gsub! /ç/, 'c' string.gsub! /&/, 'e' string.gsub! /\s/, '-' string.gsub! /[^a-zA-Z_0-9-]/, '' string.gsub! /-(-)+/, '-' string end
But when I try to start the server, I got this error:
<internal:lib/rubygems/custom_require>:29:in `require': /Users/.../lib/nzn_string.rb:11: invalid multibyte char (US-ASCII) (SyntaxError) /Users/.../lib/nzn_string.rb:11: invalid multibyte char (US-ASCII) /Users/.../lib/nzn_string.rb:11: syntax error, unexpected $end, expecting keyword_end string.gsub! /á|ã|à|ä|â/, 'a' ^
from: 29: to `require '
What is the right way to do this on ruby 1.9? I do not know what is missing here.
ruby ruby-on-rails-3 ascii
Tiago Sep 09 '10 at 15:44 2010-09-09 15:44
source share