[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: remove non-ASCII characters in a string

Levin Alexander

1/24/2006 4:49:00 PM

On 1/22/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:> I have a need for something like this as well. But I need to> replace the chars with something plain ascii besides a placeholder.> Any ideas how to do that?What I have now looks like this: # basic usage "schön".asciify #=> "sch?n" # with mapping map = Asciify::Mapping.new(:default) "„foo"".asciify(map) #=> '"foo"' Asciify.new(map).convert("schön") #=> "schoen" Asciify.new(Asciify::HTMLEntities.new).convert("schön") #=> "sch&#246;n"Mapping.new(:default) reads the mappings from a YAML file, you can useMapping.new("file.yaml") to load your own mappings or supply a Hash orlambda to Asciify.new.I have put it on rubyforge. This is my very first piece of releasedcode I'd very much like to hear your comments and criticism.I'll try to work in the posted mappings.Regards,Levin