Consultor Eletrônico



Kbase P118258: How to clean a given field from all invisible characters except the space character?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   24/08/2006
Status: Unverified

GOAL:

How to clean a given field from all invisible characters except the space character?

GOAL:

How to remove all the invisible characters from a character field of a given table?

FIX:

The following code will remove all the invisible characters except the blank space, CHR(32), from the Item.CatDescription field:
FUNCTION CleanString RETURNS CHARACTER (INPUT ipcString AS CHARACTER) FORWARD.
FOR EACH ITEM EXCLUSIVE-LOCK:
ASSIGN
Item.CatDescription = CleanString(Item.CatDescription).
END.
FUNCTION CleanString RETURNS CHARACTER (INPUT ipcDirtyString AS CHARACTER):
DEFINE VARIABLE cCleanedUpString AS CHARACTER NO-UNDO.
DEFINE VARIABLE cCurrentCharacter AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCharacterCounter AS INTEGER NO-UNDO.
DO iCharacterCounter = 1 TO LENGTH(ipcDirtyString):
cCurrentCharacter = SUBSTRING(ipcDirtyString, iCharacterCounter, 1).
IF ASC(cCurrentCharacter) > 31 AND ASC(cCurrentCharacter) < 127 THEN
cCleanedUpString = cCleanedUpString + cCurrentCharacter.
END.
RETURN cCleanedUpString.
END FUNCTION.