myReplace function for accentued chars [Solved]
Posted: Mon Jun 02, 2014 1:01 pm
Hi to all,
I want to replace chars in a string by special chars for french language (and others).
I already know the internal function Replace like:
but I've noticed that this function is not stabble and don't do the job always very well.
So I decided to build mine; here is what I do:
Until here, everything is OK. The problem is when I want to reconstruct the string <laChaine> like below:
What I get is a strange order in the string.
For example if the string is "Nom commun", with the reverse process, I get "Nom commnu"
In the debugger, I can notice that the repeat loop read the key "Nom commun" of tArray like 1,2,3,4,5,6,7,8,10,9
If they are some <cr> in the string, like <line1><line2><line3>, I get <line1><line3><line2>
Any idea what's wrong in this process ?
Thanks in advance, Jean-Paul.
I want to replace chars in a string by special chars for french language (and others).
I already know the internal function Replace like:
Code: Select all
replace "À" with "À" in laChaine -- Alt + 0192
So I decided to build mine; here is what I do:
Code: Select all
local tArray -- We keep each char of <laChaine> into that array
repeat with xxx = 1 to the number of chars of laChaine -- <laChaine> is a string which can be long
put char xxx of laChaine into tArray[xxx]
end repeat
repeat for each line xxx in the keys of tArray
put tArray[xxx] into laLettre -- <laLettre> is a char of the string <laChaine>
switch laLettre
case "à"
put "Ã" into tArray[xxx]
break
case "À" // Alt + 0192
put "À" into tArray[xxx]
break
Etc.
Code: Select all
repeat for each line xxx in the keys of tArray
put tArray[xxx] into laLettre
put laLettre after leTexte
end repeat
For example if the string is "Nom commun", with the reverse process, I get "Nom commnu"

In the debugger, I can notice that the repeat loop read the key "Nom commun" of tArray like 1,2,3,4,5,6,7,8,10,9

If they are some <cr> in the string, like <line1><line2><line3>, I get <line1><line3><line2>

Any idea what's wrong in this process ?
Thanks in advance, Jean-Paul.