From: Hu Ma Date: 2007-01-20T20:02:55+09:00 Subject: Re: transform non-english text Hello, Thanks for your help. I will try both approaches to see what fits best. Best regards, Migrate Martin Boese wrote: > I don't think there is a unified mapping table to transform > non-[^a-zA-Z0-9] > characters into a specific one of them. But if you can concider to write > a > map yourself try something like: > > > class String > MAP = [[/端/, 'u'], > [/旦/, 'o']] > > def eng_char > res = String.new(self) > MAP.each { |r| res = res.gsub(r[0],r[1]) } > return res > end > > end > > s = "ab端c端旦旦" > puts s + " => " + s.eng_char > > ---------- > Will output: > > ab端c端旦旦 => abucuoo > > > Martin -- Posted via http://www.ruby-forum.com/.