Special characters ▒ on screen

Hi
how to convert characters that do not print correctly on screen: ▒

Thank you,
Cheers

Where do they come from and what do you expect them to print as ?

Natural has a MASK function which can check for printable characters.

DEFINE DATA LOCAL
1 #STRING (A15)
         INIT <H'48656C6C6F2C017468657265212020'>  /* 'Hello, there!'
         1 REDEFINE #STRING
  2 #CHAR (A1/15)
1 #I (I4)
END-DEFINE
WRITE 'Before:' #STRING
FOR #I = 1 15
  IF  #CHAR (#I) <> MASK (P)
    THEN
      RESET #CHAR (#I)
  END-IF
END-FOR
WRITE ' After:' #STRING
END

You may find that you and Natural disagree on some characters. To find those that are printable but don’t pass the MASK test, try this:

DEFINE DATA LOCAL
1 #I4 (I4)    1 REDEFINE #I4
*   2 FILLER 3X    /* for Big Endian
  2 #CHAR (A1)
END-DEFINE
FOR #I4 = 0 255
  IF  #CHAR = MASK (P)  /* Printable?
    THEN
      WRITE 'Yes' #CHAR #CHAR (EM=H)
    ELSE
      WRITE 'No ' #CHAR #CHAR (EM=H)
  END-IF
END-FOR
END

If you need to define your own set of non-printable characters:

DEFINE DATA LOCAL
1 #BAD-ALL (A32)
         INIT <H'000102030405060708090A0B0C0D0E0F'
              -H'101112131415161718191A1B1C1D1E1F'
              >
         1 REDEFINE #BAD-ALL
  2 #BAD (A1/32)
1 #STRING (A15)
         INIT <H'48656C6C6F2C017468657265212020'>  /* 'Hello, there!'
END-DEFINE
WRITE 'Before:' #STRING
EXAMINE #STRING FOR #BAD (*) REPLACE ' '
WRITE ' After:' #STRING
END
1 Like

Thanks, I’ll try the exercise

I get the character from a query and I need to see it on the screen; but I don’t know its content