Upcase special chars (åäöü...)?

Hey guys

How do you upcase the special characters (åäöü)?
I use latin-1 and not utf-8.

How did you solve this problem? (nice ruby way or ugly hack doesnt
matter)

Daniel

Ok, this is what I have come up with so far… pretty ugly, but it
works.

def myupcase(stringtoupper)
stringtoupper.upcase.gsub(‘Ã¥’,‘Ã?’).gsub(‘ä’,‘Ã?’).gsub(‘ö’,‘Ã?’).gsub(‘ü’,‘Ã?’).gsub(‘ñ’,‘Ã?’).gsub(‘ï’,‘Ï’)
end

//Daniel

Ok, this is what I have come up with so far… pretty ugly, but it
works.

def myupcase(stringtoupper)
stringtoupper.upcase.gsub(‘å’,‘Å’).gsub(‘ä’,‘Ä’).gsub(‘ö’,‘Ö’).gsub(‘ü’,‘Ü’).gsub(‘ñ’,‘Ñ’).gsub(‘ï’,‘Ï’)
end

How about:

stringtoupper.upcase.tr(‘åäöüñï’,‘ÅÄÖÜÑÏ’)

Regards,
Rimantas

http://rimantas.com/

Hello,

Ok, this is what I have come up with so far… pretty ugly, but it
works.

def myupcase(stringtoupper)
stringtoupper.upcase.gsub(‘Ã¥’,‘Ã?’).gsub(‘ä’,‘Ã?’).gsub(‘ö’,‘Ã?’).gsub(‘ü’,‘Ã?’).gsub(‘ñ’,‘Ã?’).gsub(‘ï’,‘Ï’)
end

In this case, you can use String#tr :

stringtoupper.upcase.tr(‘åäöüñï’, ‘Ã?Ã?Ã?Ã?Ã?Ï’)

 -- Jean-François.

Daniel wrote the following on 19.04.2006 13:33 :

If you don’t need the old upcase behaviour, you can put the following
where needed (probably in lib/string_overload.rb and 'require’d in
application.rb and/or application_helper.rb):

class String
alias_method :old_upcase, :upcase
def upcase
self.old_upcase.tr(‘åäöüñï’, ‘Ã?Ã?Ã?Ã?Ã?Ï’)
end
end