View previous topic :: View next topic
|
Author |
Message |
bittu Warnings : 1 New User
Joined: 07 Jan 2007 Posts: 19 Location: Bangalore
|
|
|
|
Hi,
How do we check whether a string contains all ASCII characters in a COBOL program?
Thanks |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
in standard/old ascii only values 000-127 are valid
in extended ascii all 256 bit configurations are valid
the best approximation You can have,
according to encoding convention, is to find out if the string is printable
but as usual You have to express Your requirement better |
|
Back to top |
|
|
bittu Warnings : 1 New User
Joined: 07 Jan 2007 Posts: 19 Location: Bangalore
|
|
|
|
Thanks to all.
Below is the explaination abt this requirement:
I need to read a value in to a Working storage variable from an input file. How do I check whether the value(say "FRANCE") in the variable is made up of ASCII charcaters?
Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
I think some real thought needs to be given to this requirement. For example, you have a variable that has one character in it; that character's hexadecimal value is 4E (78 decimal). In EBCDIC that is a plus sign but in ASCII it is an upper case N. Which way you refer to it depends on how you want to use it -- there is absolutely no inherent meaning to the character.
So in general, you cannot tell automatically if a given variable has EBCDIC or ASCII data in it since each character represents BOTH an ASCII value as well as an EBCDIC value. If I see a batch of hex '40' values in the variable I'm going to suspect EBCDIC whereas a batch of hex '20' values means I'm going to be thinking ASCII -- but I've seen cases where both of those assumptions are wrong. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
How do we check whether a string contains all ASCII characters in a COBOL program? |
If you are reading from an "input file", it is more than 99% likely that you are reading ebcdic characters.
The most common way i've seen ascii characters in a file read on the mainframe is when someone made a mistake transferring the file to the mainframe. They sent the file in binary causing the resulting data to still be in ascii. Whenever this happened, the file transfer is correct so that the resulting data is ebcdic on the mainframe. |
|
Back to top |
|
|
|