Diacritical Marks and matching text

Cubist at aol.com Cubist at aol.com
Sun Mar 24 16:41:01 EST 2002


   If you want to do operations on diacritical-laden text that ignores the 
diacritical marks, one obvious solution would be a function that replaces 
diacritical'ed characters with their plain equivalents. Once you've done that 
job, something like this might work...

   Two constants are required. First, construct a string that consists of all 
possible diacritical'ed characters, and put it into a variable called 
"FancyChar". Next, replace all the diacritical'ed characters in FancyChar 
with their non-diacriticaled equivalents; the resulting string goes into a 
variable called "PlainChar".

  function StripDiacriticals DaText
    put 0 into DaKount
    repeat with each character Dia of FancyChar
      add 1 to DaKount
      put offset (Dia, DaText) into Zelda
      put char DaKount of PlainChar into BoringChar
      repeat while Zelda <> 0
        put BoringChar into char Zelda of DaText
      end repeat
    end repeat
    return DaText
  end StripDiacriticals

   This is heavily HyperCard influenced; I haven't messed with MetaCard 
enough to know whether there are any subtle differences that would make this 
function misbehave in MC/Rev. Be that as it may, the underlying logic should 
be fairly clear...
   Hope this helps!



More information about the use-livecode mailing list