At 09:58 -0600 on 12/29/2011, McKown, John wrote about Is a byte "printable"?:

Is there a simple way in HLASM to determine if a byte can be
consider "printable", assuming the standard EBCDIC code page of
CP-37 or IBM-1047? I would guess that the simpliest way is to have a
256 byte table and use the byte as an index. If the byte value is,
for example, not zero (or the other way around), then the byte is
printable. Then just populate that table "by hand". Is there a macro
buried somewhere which has this information in it?

There is no table that I know of but it is not hard to code. Here is
the first 64 entries:

     DC 64X"FF" (covers X"00"-X"3F")

The lower case letters (starting at X"80") and upper case letters at
x"C0") are:

    DC X"FF",9X"00",6X"FF",X"FF",9X"00",6X"FF",X"FFFF",8X"00",6X"FF"

The numbers at X"F0" are:

   DC 10X"00",6X"FF"

FF means that the character is not printable while 00 is printable.
Note: Go to http://en.wikipedia.org/wiki/EBCDIC for a table of the
glyphs so you know what you need to code (I am ignoring all the
special symbols in the letter ranges above so my mappings are no 100%
accurate).


What I'm doing is writing a subroutine to "encode" a string. If the
byte is "printable", just move it into the output buffer. If it is
not "printable", then output a three byte sequence: %hh where hh is
the hex encoding. Or is there a better encoding method? I want
"printable" so that I can output the data which I'm getting from an
ISQUERY result. The RNAME (and QNAME) __may__ have "unprintable"
characters in them. Or even characters which are "printable", but
which I want encoded, such as a blank, for other reasons (such as
parsing). And I want it simple to decode. Which, to me, means a
fixed length string. None of the HTML stuff like & and <.'

You can use TRT and the above table to scan the input string. It will
stop when you hit an entry in the table of FF. You the use the length
of the block of 00 hits to move the characters to the print area and
then form/move %hh for the character you stopped at. Note: If your
input string contains a % you will need to convert it to %6C to avoid
that case where the sting has %hh (which both h's are a-f or 0-9)
which  can be confused with a non-printable character. I am glossing
over all the processing but this should give you a start.

Reply via email to