I need to convert strings with international characters to strings
with corresponding ASCII codes. For example é, è, ë, and ê (and all
other e-related versions) should convert to e and so on.
I need to convert strings with international characters to strings
with corresponding ASCII codes. For example é, è, ë, and ê (and all
other e-related versions) should convert to e and so on.
I once did something very crude, which for your purpose would look
something like this:
def preprocess(query)
normalized = query.chars.normalize :d
processed = ""
normalized.u_unpack.each do |c|
if c >= 0x300 && c < 0x370 #combining marks
else
processed << [c].pack('U*')
end
processed
end