I just optimized the preceeding procedure. It is now 400 times faster!
Code: Select all
Procedure.s RemoveAccents(Text$)
; Function to remove accents from a string. By Zapman.
If Text$
Protected length = Len(Text$) * 2
Protected OPos, NPos, DoubleLength
Protected NormalizedText$ = Space(Length)
;
; FoldString_() will replace each accentuated character by a pair of characteres
; as this: (NonAccentuatedCharactere) + (diacritic)
Length = FoldString_(#MAP_COMPOSITE, @Text$, - 1, @NormalizedText$, Length) - 1
;
; Examine the result:
If Length > 0 And Length <> Len(Text$)
DoubleLength = (Length - 1) * 2
For NPos = 0 To DoubleLength Step 2
If PeekC(@Text$ + OPos) <> PeekC(@NormalizedText$ + NPos)
; If the character has been replaced, replace it into the original text:
PokeC(@Text$ + OPos, PeekC(@NormalizedText$ + NPos))
; The following character contains the diacritic. Jump over it:
NPos + 2
EndIf
OPos + 2
Next
EndIf
;
ProcedureReturn Text$
EndIf
EndProcedure