14

SUN/40.6

Starlink Project
Starlink User Note 40.6

A C Charles
P C T Rees
A J Chipperfield
T Jenness
D Berry

16 May 2018

Copyright © 2018 East Asian Observatory


CHR
Character Handling Routines

3.0

Programmer’s Manual



Abstract

This document describes the Character Handling Routine library, CHR, and its use. The CHR library augments the limited character handling facilities provided by the Fortran 77 standard. It offers a range of character handling facilities: from formatting Fortran data types into text strings and the reverse, to higher level functions such as wild card matching, string sorting, paragraph reformatting and justification. The library may be used simply for building text strings for interactive applications or as a basis for more complex text processing applications.

Contents

1 Introduction
2 Error Handling
3 Compiling and Linking
4 Efficiency Considerations
A Include Files
B Classified List of Routines
 B.1 Change case
 B.2 Compare strings
 B.3 Decode Fortran data types
 B.4 Edit strings
 B.5 Encode Fortran data types
 B.6 Enquire
 B.7 Facilitate Portability
 B.8 Search strings
C Routine Descriptions
CHR_ABBRV – Return whether two strings are equal apart from case, permitting abbreviations
CHR_ACHR – Return the character for a given ASCII value
CHR_APPND – Copy one string into another, ignoring trailing blanks
CHR_ATOK – Return the character for a given ASCII character token
CHR_ATOM – Translate a string from ASCII to the machine’s character set
CHR_BTOI – Read an INTEGER value from a binary string
CHR_CLEAN – Remove all unprintable characters from a string
CHR_COPY – Copy one string to another, checking for truncation
CHR_CTOC – Write a CHARACTER string into another string
CHR_CTOD – Read a DOUBLE PRECISION value from a string
CHR_CTOI – Read an INTEGER value from a string
CHR_CTOL – Read a LOGICAL value from a string
CHR_CTOR – Read a REAL value from a string
CHR_DCWRD – Split a string into its component words
CHR_DELIM – Locate a substring using a given delimiter character
CHR_DTOAN – Write a DOUBLE PRECISION value into a string as hr/deg:min:sec
CHR_DTOC – Encode a DOUBLE PRECISION value as a string
CHR_EQUAL – Return whether two strings are equal
CHR_ETOM – Translate a string from EBCDIC to the machine’s character set
CHR_FANDL – Find the first and last non-blank characters in a string
CHR_FILL – Fill a string with a given character
CHR_FIND – Find the next occurrence of given substring within a string
CHR_FIWE – Find the next end-of-word within a string
CHR_FIWS – Find the start of the next word within a string
CHR_FPARX – Find a parenthesised expression in a character string
CHR_HTOI – Read an INTEGER value from a hexadecimal string
CHR_IACHR – Return the ASCII value for the given character
CHR_INDEX – Return the index of a substring in a string
CHR_INSET – Return whether a string is a member of a given set
CHR_ISALF – Return whether a character is alphabetic
CHR_ISALM – Return whether a character is alphanumeric
CHR_ISDIG – Return whether a character is a digit
CHR_ISNAM – Return whether a string is a valid name
CHR_ITOB – Write an INTEGER value into a binary string
CHR_ITOC – Encode an INTEGER value as a string
CHR_ITOH – Write a hexadecimal string from an INTEGER value
CHR_ITOO – Write an octal string from an INTEGER value
CHR_LASTO – Locates the last occurence of CVAL in STRING
CHR_LCASE – Convert a string to lowercase
CHR_LDBLK – Remove any leading blanks from a string
CHR_LEN – Return the length of a string, ignoring trailing blanks
CHR_LINBR – Break a line of text into a sequence of shorter lines
CHR_LOWER – Return the lowercase equivalent of a character
CHR_LTOC – Encode a LOGICAL value as a string
CHR_MOVE – Move one string into another
CHR_MTOA – Translate a string from the machine’s characters set to ASCII
CHR_MTOE – Translate a string from the machine’s character set to EBCDIC
CHR_NTH – Return the two-character ordinal abbreviation for a specified integer
CHR_OTOI – Read an INTEGER value from an octal string
CHR_PFORM – Reformat a paragraph to a new width
CHR_PREFX – Prefix a string with a substring
CHR_PUTC – Put a CHARACTER string into another at a given position
CHR_PUTD – Put a DOUBLE PRECISION value into a string at a given position
CHR_PUTI – Put an INTEGER value into a string at a given position
CHR_PUTL – Put a LOGICAL value into a string at a given position
CHR_PUTR – Put a REAL value into a string at a given position
CHR_RJUST – Right-justify a string
CHR_RMBLK – Remove all blanks from a string
CHR_RMCHR – Remove all specified characters from a string
CHR_RTOAN – Write a REAL value into a string as hr/deg:min:sec
CHR_RTOC – Encode a REAL value as a string
CHR_SCOMP – Compare two character strings using the ASCII character set
CHR_SIMLR – Return whether two strings are equal, apart from case
CHR_SIZE – Return the declared size of a string
CHR_SKCHR – Skip over all specified characters in a string
CHR_SORT – Sort an array of character variables into alphabetical order
CHR_SWAP – Swap two single-character variables
CHR_TERM – Terminate a string by padding out with blanks
CHR_TOCHR – Skip to the next specified character in a string
CHR_TRCHR – Translate the specified characters in a string
CHR_TRUNC – Truncate a string at a given delimiter
CHR_UCASE – Convert a string to uppercase
CHR_UPPER – Return uppercase equivalent of a character
CHR_WILD – Return whether a string matches a wild-card pattern

D C Function Descriptions
 D.1 Overview
chrAppnd – Copy one string into another, ignoring trailing blanks
chrClean – Remove all unprintable characters from a string
chrCtod – Read a double value from a string
chrCtoi – Read an integer value from a string
chrCtor – Read a float value from a string
chrFandl – Find the first and last non-blank characters in a string
chrFill – Fill a string with a given character
chrFparx – Find a parenthesised expression in a character string
chrIsalm – Return whether a character is alphanumeric
chrIsnam – Return whether a string is a valid name
chrItoc – Encode an integer value as a string
chrLdblk – Remove any leading blanks from a string
chrLen – Return the length of a string, ignoring trailing spaces
chrPutc – Put a character string into another at a given position
chrPuti – Put an integer value into a string at a given position
chrRmblk – Remove all blanks from a string
chrSimlr – Return whether two strings are equal, apart from case
chrSimlrN – Return whether the starts of two strings are equal, apart from case
chrSizetoc – Encode a size_t value as a string
chrUcase – Convert a string to uppercase

E Portability
 E.1 Overview
 E.2 Coding and porting prerequisites
 E.3 Operating system specific routines
F Changes and New Features in Version 2.0
 F.1 Obsolete routines
 F.2 Changes in behaviour of existing routines
 F.3 New routines
 F.4 Other changes
G Changes and New Features in Version 2.2
 G.1 Changes in behaviour of existing routines
 G.2 Documentation Changes
H Changes and New Features in Version 3.0