I can use the
iconv command to "translit" a utf-8 string to an ASCII-only string with characters being replaced with their closest ASCII character. However, my problem is that I need the resulting string to contain exactly the same number of characters (code points) as the source string. For example the British pound (
£) character is being replaced with three characters (
GBP) or the character
æ with the two characters
ae. Instead, I want these characters to be replaced with a single character (for example,
e). Is there a method / option for this?
I am trying to develop an "ASCII-based" find routine for Latin-based text. For example,
find 'uco' in '£Húçôz' should return position 3 (I am counting from 1 for the first position) and not 5 (because
£ is expanded to 3 characters and not one). Please, note that, what I am trying to develop is much more complex; I have tried to simplify my question as much as possible here.
Also note that, this find routine need not be perfect in matching non-ASCII Latin-based text strings, but the (first) position of the match (if there is one) should point to the correct character (code point) position.