Remove Special Character From Text

 Shakil Hasan

FSA Software Inc.


Recently one of our users faced this issue in printing/previewing a report: when a report is printed from NAV, some empty square boxes are printed between spaces for a BLOB field; this indicates that there are some special characters in the text, which printer or monitor could not interpret, when printed/previewed from NAV.

I have created this function to get rid off the special characters.

    LOCAL PROCEDURE RemoveSpecialCharacters@100000000(ptxtDirty@100000003 : Text) rtxtClean : Text;

    VAR

      AllowedChars@100000004 : Text;

      specialCharacter@100000005 : Text;

      LF@100000006 : Char;

      CR@100000007 : Char;

      SP@100000008 : Char;

      SQ@100000009 : Char;

    BEGIN

      LF:=10;

      CR:=13;

      SP:=32;

      SQ:=39;

      AllowedChars := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-;Á,@!.#%@~*(){}[]<>?/\|"0123456789'+FORMAT(LF)+FORMAT(CR)+FORMAT(SP)+FORMAT(SQ);

      specialCharacter:=DELCHR(ptxtDirty,'=',AllowedChars);

      rtxtClean:=DELCHR(ptxtDirty,'=',specialCharacter);

    END;

Comments