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 -- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.
> 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(''?'',''?'') > endHow 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(''?'',''?'') > endIn this case, you can use String#tr : stringtoupper.upcase.tr(''??????'', ''??????'') -- Jean-Fran?ois. -- ? la renverse.
Daniel wrote the following on 19.04.2006 13:33 :>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 > > >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