Ruby from any encoding to ascii

I have to deal mainly with English alphabets and all punctuation marks, I do not need to worry about European accents. So the only thing I have is when the user inserts something that he copies from the Internet, including, for example, the apostrophe, which when I put into the console (on Win7) displays

"ItΓÇÖs" #, where he really is "It"

So my main question is whether there is an end-to-end conversion method for everyone that I can use in Ruby that correctly replaces all elements., ?? "'~` _- using ASCII counter elements?

I really know very little about encodings, if you think that this is the wrong question that may arise, and perhaps this is so, please give advice on what I should look for instead.

thank

+5
source share
3 answers

I am working on a publication where we deal with this a lot. We had success with stringex https://github.com/rsl/stringex . They have a to_ascii method that normalizes the unicode dash, etc.

+6
source

For software processing multi-byte encodings iconvis your friend. And James Gray wrote a series of articles talking about how to split the problem and convert encodings.

, , , . , , Ruby, , , , , . .

+1

And in ruby ​​2.0:

"ItΓÇÖs".encode("ASCII", invalid: :replace, undef: :replace, replace: '')
 => "Its" 
+1
source

All Articles