M400: Portable Conversion Between Type CHARACTER and Type INTEGER
Author(s): H. Renshall | Library: KERNLIB
|
Submitter: M. Metcalf | Submitted: 27.11.1984
|
Language: Fortran | Revised: 12.03.1985
|
CHTOI converts between a CHARACTER*1 value in a
95-character set and INTEGER values in the range 32-126 via a
look-up table.
Structure:
SUBROUTINE subprogram
User Entry Names: CHTOI, ITOCH
Usage:
CALL CHTOI(CHAR,INTGR,*label)
- CHAR
- (CHARACTER*1) Variable or constant (may be a
substring of a longer string) containing on input the character for
which the integer equivalent is required.
- INTGR
- (INTEGER) Variable which will contain on output the
integer equivalent from a look-up table of the input character argument.
A zero will be returned if the character was not found in the table.
- label
- (INTEGER) Label of an executable statement within the
calling program to which control will be transferred should the input
character not be found in the table.
CALL ITOCH(INTGR,CHAR,*label)
- CHAR
- (CHARACTER*1) variable which will contain on output
the character equivalent from a look-up table of the input integer
argument. A question mark will be returned if the integer is outside the
range inclusive.
- INTGR
- (INTEGER) variable or constant containing on input an
integer in the range for which the character equivalent is
required.
- label
- (INTEGER) Label of an executable statement in the
calling program to which control will be transferred should the input
integer be outside the range .
Method:
A look-up table containing 95 entries is mapped
consecutively into integers . The table is as follows:
32- 47: ! " # $ % & ' ( ) * + , - . / (32 is a blank)
48- 57: 0 ... 9
58- 64: : ; < = > ? @
65- 90: A ... Z
91- 96: [ \ ] ^ _ `
97-122: a ... z
123-126: { | } ~
Restrictions:
This routine is typed in Fortran on a system
which includes all the above characters. Systems with fewer
characters available usually make some local translation when they read
the source for example on CDC NOS/BE the lower case letters are
translated to upper case. Exact reproducibility of other than the subset
of characters is not guaranteed.
Notes:
These integer values are the same as for the 8-bit ASCII set.
Michel Goossens
Wed Jun 5 07:10:19 METDST 1996