Hey guys ''öçğüş''.chars.upcase => "ÖÇĞÜŞ" work perfectly How do you gsub the special characters (åäöü)? I use utf-8 rails 1.2. "AÖŞaöş".chars.gsub(/([aöş])/i, '' •\1• '') => •A• ÖŞ •a• •ö• •ş• gsub not work in unicode characters How did you solve this problem? Ferit -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 12, 2007, at 6:45 AM, Ferit Öztosun wrote:> ''öçğüş''.chars.upcase => "ÖÇĞÜŞ" work perfectly > > How do you gsub the special characters (åäöü)? > I use utf-8 rails 1.2. > > > "AÖŞaöş".chars.gsub(/([aöş])/i, '' •\1• '') > => •A• ÖŞ •a• •ö• •ş• > > gsub not work in unicode characters > > How did you solve this problem?I spent several days working on this and finally managed to piece together some help from the ruby list. If you''re into understanding it all, try this thread: http://www.ruby-forum.com/topic/133538 First, make sure you have this line at the top of your environment.rb file: $KCODE = ''UTF8'' Next, make sure your regex ends with /u as in /\w+/u Finally, this is how you specify UTF-8 characters: ''üéåë''.gsub(/#{"\303\253"}/u, ''x'') Ranges would like /#{"\303\200"}-#{"\303\226"}/u You have to use the octal numbers, so that one above would replace ë with x. -- def gw acts_as_n00b writes_at(www.railsdev.ws) end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> $KCODE = ''UTF8'' > > Next, make sure your regex ends with /u as in /\w+/u > > Finally, this is how you specify UTF-8 characters: > > ''üéåë''.gsub(/#{"\303\253"}/u, ''x'') > > Ranges would like /#{"\303\200"}-#{"\303\226"}/u > > You have to use the octal numbers, so that one above would replace ë > with x.Sory i explained missing i can do already unicode in regex example: ''üéåëË''.gsub(/ë/, ''x'') => üéåxË but i want to unicode with ignorecase /i because search result must be with bold example: ''üéåËafe''.gsub(/(åë)/i, ''<b>\1</b>'' result must be like => "üé<b>åË</b>afe", but ignorecase not work ''ë''.chars.upcase => "Ë" work perfectly -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---