is there a good way to convert "special" accented chars to their base chars? as an example i want "àéìòù" => "aeiou" i''m using several gsub now "àèìòù".gsub("à","a").gsub("è","e").gsub("ì","i")... it works but i wonder if there is something better than this. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Well something like char_from = "àéìòù" char_to = "aeiou" x = "àéìòù".gsub(char_from, char_to) puts x would at least make the code more maintainable -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
your code convert only that sequence of character. what i need is to convert those accented char in every word. so "città" => "citta", "caffè" => "caffe" and so on maybe some regexp? On 10 Mag, 12:50, Peter Hickman <peterhickman...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Well something like > > char_from = "àéìòù" > char_to = "aeiou" > > x = "àéìòù".gsub(char_from, char_to) > puts x > > would at least make the code more maintainable-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Mmm Just noticed another problem char_from = "àéìòù" char_to = "aeiou" puts char_from.size => 10 puts char_to.size => 5 At least on my Mac. The problem here is encoding. Looks trickier than I first thought, would be a cinch if this was unicode and we were using Java :) Just decompose the unicode character and drop the accent characters. Ignore everything I have said and lets hope someone who knows about this can suggest a solution, I am intrigued by this. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
I''m having this very same problem when String.upcase() is not uppercasing accentuated characters. It seems that the problem is the encoding again. regards 2010/5/10 Peter Hickman <peterhickman386-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>:> Mmm > Just noticed another problem > char_from = "àéìòù" > char_to = "aeiou" > puts char_from.size => 10 > puts char_to.size => 5 > At least on my Mac. The problem here is encoding. > Looks trickier than I first thought, would be a cinch if this was unicode > and we were using Java :) Just decompose the unicode character and drop the > accent characters. > Ignore everything I have said and lets hope someone who knows about this can > suggest a solution, I am intrigued by this. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- ------------------------------------ Oliver Hernàndez Valls http://codit.wikidot.com http://wiki.tramuntanal.cat -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
eugenio wrote:> your code convert only that sequence of character. what i need is to > convert those accented char in every word. > so "citt�" => "citta", "caff�" => "caffe" and so on > maybe some regexp?You''ll probably have to convert your text to normal form D or KD, then filter out combining marks. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.