Replace accents

Ludovic THEBAULT ludovic.thebault at laposte.net
Tue May 10 10:22:45 EDT 2016


Le 10 mai 2016 à 15:14, John Dixon <dixonja at hotmail.co.uk> a écrit :

> err... it does work under LC8.. just tried it
> MacBook Pro, El Capitan, OSX 10.11.4


If the text is typed with Livecode, it's work, but with a text opened from a file (or the list of files in a folder, like i use in this script, it doesn't work).

try : 

on mouseup
   put "Bonjour à tous" into URL("file:" & specialfolderpath("Documents")&"/bonjouràtous.txt")
   set the defaultfolder to  specialfolderpath("Documents")
   get the files
   filter it with "bonjour*"
   get noaccents(it)
   answer it
end mouseup

function noaccents myText
put "áàâäãåÄÅÀÃéèêëÊËÈÉíìîïÍÎÏÌóòôöõÓÔÒÕÖúùûüÚÛÙÜÑñçÇ'" into accent
   put "aaaaaaAAAAeeeeEEEEiiiiIIIIoooooOOOOOuuuuUUUUNncC_" into noaccent

   put 0 into cpt
   repeat for each char i in accent
      add 1 to cpt
      --if i = "É" then breakpoint
      replace i with char cpt of noaccent in myText
   end repeat
return myText
end noaccents



More information about the Use-livecode mailing list