non-ASCII characters into equivalent ASCII

What is the correctr Ruby-way to transform non-ASCII characters into
their sort-of equivalent ASCII characters?

That is, how do I transform, say, Turkish characters ýðüþöçÝÐÜÞÖÇ into
corresponding igusocIGUSOC? For Russian the excellent rutils gem
exists. What about other languages? Or at least those with scripts
based on Latin.

Thank you

What is the correctr Ruby-way to transform non-ASCII characters into
their sort-of equivalent ASCII characters?

That is, how do I transform, say, Turkish characters ýðüþöçÝÐÜÞÖÇ into
corresponding igusocIGUSOC? For Russian the excellent rutils gem
exists. What about other languages? Or at least those with scripts
based on Latin.

Ok, found my own way:

Using Unicode and Rutils gems:

str = Unicode::decompose(string).bidi_translify(false)

Works like a charm :slight_smile:

On 06/07/06, Dmitrii D. [email protected] wrote:

Using Unicode and Rutils gems:

str = Unicode::decompose(string).bidi_translify(false)

Interesting. I didn’t know Rutils could do that (and why would I? I
can’t read Russian!)

Paul.

On 7/6/06, Paul B. [email protected] wrote:

On 06/07/06, Dmitrii D. [email protected] wrote:

Using Unicode and Rutils gems:

str = Unicode::decompose(string).bidi_translify(false)

Interesting. I didn’t know Rutils could do that (and why would I? I
can’t read Russian!)

Well, Ruils simply transliterate from-to Latin-Cyrillic.
bidi_translify additionally removes “insignificant” characters such as
commas and the like, which works well on decomposed Unicode strings.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs