IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to check ASCII in a string


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bittu
Warnings : 1

New User


Joined: 07 Jan 2007
Posts: 19
Location: Bangalore

PostPosted: Thu Sep 18, 2008 12:12 pm
Reply with quote

Hi,

How do we check whether a string contains all ASCII characters in a COBOL program?

Thanks
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Sep 18, 2008 12:36 pm
Reply with quote

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
View user's profile Send private message
bittu
Warnings : 1

New User


Joined: 07 Jan 2007
Posts: 19
Location: Bangalore

PostPosted: Thu Sep 18, 2008 1:17 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Sep 18, 2008 5:09 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Sep 18, 2008 8:59 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top