Page 1 of 1

Converting accented characters to ASCII 128

Posted: Wed Aug 26, 2009 7:49 pm
by paul@researchware.com
Does anyone have a code snippet for converting accented characters to lower (<128) ASCII equivalents? Example: ë to e OR À to A and so on?

Any help is much appreciated

Posted: Wed Aug 26, 2009 8:59 pm
by bn
Paul,
welcome to the forum.
I dont have such a function handy, it would be easy to do it yourself.
make a field and a button. In the button you put

Code: Select all

on mouseUp 
    repeat with i = 128 to 255
        put numtochar(i) & "," after field 1
    end repeat
    delete last char of field 1 -- comma
end mouseUp
Now you group your high ASCII characters like

Code: Select all

Ä,Ã…,À,Ã,Â,Ã

Posted: Wed Aug 26, 2009 9:32 pm
by paul@researchware.com
Thanks. That's what I came up with after a couple Google searches for algorithms to do thsi and found most all were table lookups. He're the function I wrote if it helps any one else:

Code: Select all

function toASCII128 pText
  local tAccents, tASCII, tSpecials, tText, tChar
  
  put "ÀÃ

Posted: Wed Aug 26, 2009 10:22 pm
by Mark
Hi Paul,

You probably need to make two diffrent look-up tables, for Mac and Windows.

Best,

Mark