Lo encontré hace tiempo en Stackoverflow, pero no encuentro el link :\
class String
# remove all non 127-ASCII chars
def remove_non_ascii
n=self.split("")
self.slice!(0..self.size)
n.each { |b|
if b[0].to_i< 33 || b[0].to_i>127 then
self.concat('')
else
self.concat(b)
end
}
self.to_s
end
end
Ejemplo
puts "Ñandú" #and
Advertisement