Converting accented characters to ASCII 128

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Converting accented characters to ASCII 128

Post by paul@researchware.com » Wed Aug 26, 2009 7:49 pm

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
Paul Dupuis
Researchware, Inc.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Wed Aug 26, 2009 8:59 pm

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

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

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Post by paul@researchware.com » Wed Aug 26, 2009 9:32 pm

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 "ÀÃ
Paul Dupuis
Researchware, Inc.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Aug 26, 2009 10:22 pm

Hi Paul,

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

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply

Return to “Talking LiveCode”