distinguish between binary text and regular text

Z

zvika

How can I distinguish between binary text and regular text ?

For example:
I want to convert the value of SYSOT to hex values,
and to keep the value of SYSOT1 the same.

01 SYSOT VALUE '^@^X^@^A^@^AA' PIC X(07).
01 SYSOT1 VALUE 'ABC' PIC X(07).
 
A

Anno Siegel

zvika said:
How can I distinguish between binary text and regular text ?

That distinction doesn't make much sense. All data is binary on a
standard computer. Text is simply (binary) data intended to be
decoded and rendered in form of characters. There is no way you can
look at a piece of data and decide "This is text" or "This isn't".
For example:
I want to convert the value of SYSOT to hex values,
and to keep the value of SYSOT1 the same.

01 SYSOT VALUE '^@^X^@^A^@^AA' PIC X(07).
01 SYSOT1 VALUE 'ABC' PIC X(07).

From your example it looks like you want to recognize control characters.
That can be done with a regex and a POSIX character class:

$string =~ /[[:cntrl:]]/ and print "Contains a control character\n";

If you are looking for something else, check out other predefined
character classes or build your own.

Anno
 
J

Jürgen Exner

zvika said:
How can I distinguish between binary text and regular text ?

That depends on _your_ definition of 'binary' versus 'regular' in the
context of _your_ program, e.g. do you consider the byte sequence for a
Chinese character in UTF-8 which is encoded in Base64 to be regular text or
binary text?
For example:
I want to convert the value of SYSOT to hex values,
and to keep the value of SYSOT1 the same.

01 SYSOT VALUE '^@^X^@^A^@^AA' PIC X(07).
01 SYSOT1 VALUE 'ABC' PIC X(07).

Sorry, this example doesn't help much to explain what you want to do.
One possible interpretation could be printable versus non-printable
characters. In that case you may want to check the 'print' class in 'perldoc
perlre'.
If you mean something else then please let us know what you mean.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top