Hej, czy znacie może jakiś ładny sposób na zamianę znaków w stringach, tak aby rezultat zawierał tylko znak ASCII a wyglądał podobnie np
“żółw Ø ü” => “zolw O u”
Dla polskich znaków wystarczy mi to:
def escape_tails
chars = ["ą","Ą","ę","Ę","ó","Ó","ł","Ł","ń","Ń","ś","Ś","ć","Ć","ź","Ź","ż","Ż"]
ascii = ["a","A","e","E","o","O","l","L","n","N","s","S","c","C","z","Z","z","Z"]
chars.each_with_index do |char, i|
self.gsub!(chars[i], ascii[i])
end
self
end
Ale z zagranicznymi w ten sposób nie chcę sie już bawić.