Kbase P72697: How to replace all characters above 127 to 7-bit ascii chara
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  18/03/2004 |
|
Status: Unverified
GOAL:
How to replace all characters above 127 to 7-bit ascii characters (remove accents and others)
FIX:
Here is a little sample code:
FUNCTION RemoveAbove127 RETURNS CHAR
(c AS CHAR):
DEFINE VARIABLE iLength AS INTEGER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
/* replace accents by characters without accents */
ASSIGN
c = REPLACE(c,'é','e')
c = REPLACE(c,'è','e')
/* add same code to handle other accents here*/
c = REPLACE(c,'à','a').
/* make sure there is no character above 127, replace them by '#' (example) */
iLength = LENGTH(c).
DO i = 1 TO iLength:
IF ASC(SUBSTRING(c,i,1)) < 128 THEN NEXT.
SUBSTRING(c,i,1) = "#".
END.
RETURN c.
END FUNCTION.