stdlib_ascii#

Introduction#

The stdlib_ascii module provides procedures for handling and manipulating intrinsic character variables and constants.

Constants provided by stdlib_ascii#

NUL#

Null character

SOH#

Start Of Heading Character

STX#

Start Of Text character

ETX#

End Of Text character

EOT#

End Of Transmission character

ENQ#

Enquiry character

ACK#

Acknowledge character

BEL#

Bell character

BS#

Backspace character

TAB#

Horizontal Tab character

LF#

Line Feed character

VT#

Vertical Tab character

FF#

Form Feed character

CR#

Carriage Return character

SO#

Shift Out character

SI#

Shift In character

DLE#

Data Link Escape character

DC1#

Device Control 1 character

DC2#

Device Control 2 character

DC3#

Device Control 3 character

DC4#

Device Control 4 character

NAK#

Negative Acknowledge character

SYN#

Synchronous Idle character

ETB#

End of Transmission Block character

CAN#

Cancel character

EM#

End of Medium character

SUB#

Substitute character

ESC#

Escape character

FS#

File separator character

GS#

Group Separator character

RS#

Record Separator character

US#

Unit separator character

DEL#

Delete character

fullhex_digits#

All the hexadecimal digits (0-9, A-F, a-f)

hex_digits#

All the numerical and uppercase hexadecimal digits (0-9, A-F)

lowerhex_digits#

All the numerical and lowercase hexadecimal digits (0-9, a-f)

digits#

base 10 digits (0-9)

octal_digits#

base 8 digits (0-7)

letters#

Uppercase and lowercase letters of the english alphabet (A-Z, a-z)

uppercase#

Uppercase english albhabets (A-Z)

lowercase#

Lowercase english albhabets (a-z)

whitespace#

All the ascii whitespace characters (space, horizontal tab, vertical tab, carriage return, line feed, form feed)

Specification of the stdlib_ascii procedures#

is_alpha#

Status#

Experimental

Description#

Checks whether input character is an ASCII letter (A-Z, a-z).

Syntax#

res = is_alpha (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_alphanum#

Status#

Experimental

Description#

Checks whether input character is an ASCII letter or a number (A-Z, a-z, 0-9).

Syntax#

res = is_alphanum (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_ascii#

Status#

Experimental

Description#

Checks whether input character is in the ASCII character set i.e in the range 0-128.

Syntax#

res = is_ascii (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_control#

Status#

Experimental

Description#

Checks whether input character is a control character.

Syntax#

res = is_control (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_digit#

Status#

Experimental

Description#

Checks whether input character is a digit (0-9).

Syntax#

res = is_digit (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_octal_digit#

Status#

Experimental

Description#

Checks whether input character is an octal digit (0-7)

Syntax#

res = is_octal_digit (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_hex_digit#

Status#

Experimental

Description#

Checks whether input character is a hexadecimal digit (0-9, A-F, a-f).

Syntax#

res = is_hex_digit (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_punctuation#

Status#

Experimental

Description#

Checks whether input character is a punctuation character.

Syntax#

res = is_punctuation (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_graphical#

Status#

Experimental

Description#

Checks whether input character is a graphical character (printable other than the space character).

Syntax#

res = is_graphical (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_printable#

Status#

Experimental

Description#

Checks whether input character is a printable character (including the space character).

Syntax#

res = is_printable (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_lower#

Status#

Experimental

Description#

Checks whether input character is a lowercase ASCII letter (a-z).

Syntax#

res = is_lower (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_upper#

Status#

Experimental

Description#

Checks whether input character is an uppercase ASCII letter (A-Z).

Syntax#

res = is_upper (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_white#

Status#

Experimental

Description#

Checks whether input character is a whitespace character (which includes space, horizontal tab, vertical tab, carriage return, linefeed and form feed characters)

Syntax#

res = is_white (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

is_blank#

Status#

Experimental

Description#

Checks whether input character is a blank character (which includes space and tabs).

Syntax#

res = is_blank (c)

Class#

Elemental function.

Argument#

c: shall be an intrinsic character(len=1) type. It is an intent(in) argument.

Result value#

The result is a logical.

to_lower#

Status#

Experimental

Description#

Converts input character variable to all lowercase.

Syntax#

res = to_lower (string)

Class#

Elemental function.

Argument#

string: shall be an intrinsic character type. It is an intent(in) argument.

Result value#

The result is an intrinsic character type of the same length as string.

Example#

program example_to_lower
  use stdlib_ascii, only: to_lower
  implicit none
  print'(a)', to_lower("HELLo!") ! returns "hello!"
end program example_to_lower

to_upper#

Status#

Experimental

Description#

Converts input character variable to all uppercase.

Syntax#

res = to_upper (string)

Class#

Elemental function.

Argument#

string: shall be an intrinsic character type. It is an intent(in) argument.

Result value#

The result is an intrinsic character type of the same length as string.

Example#

program example_to_upper
  use stdlib_ascii, only: to_upper
  implicit none
  print'(a)', to_upper("hello!") ! returns "HELLO!"
end program example_to_upper

to_title#

Status#

Experimental

Description#

Returns the titlecase version of the input character variable.
Title case: First character of every word in the sentence is converted to uppercase and the rest of the characters are converted to lowercase.
A word is a contiguous sequence of character(s) which consists of alphabetical character(s) and numeral(s) only and doesn’t exclude any alphabetical character or numeral present next to either of its 2 ends.

Syntax#

res = to_title (string)

Class#

Elemental function.

Argument#

string: shall be an intrinsic character type. It is an intent(in) argument.

Result value#

The result is an intrinsic character type of the same length as string.

Example#

program example_to_title
  use stdlib_ascii, only: to_title
  implicit none
  print *, to_title("hello there!") ! returns "Hello There!"
  print *, to_title("'enquoted'") ! returns "'Enquoted'"
  print *, to_title("1st")  ! returns "1st"
end program example_to_title

to_sentence#

Status#

Experimental

Description#

Returns the sentencecase version of the input character variable.
The first alphabetical character of the sequence is transformed to uppercase unless it follows a numeral. The rest of the characters in the sequence are transformed to lowercase.

Syntax#

res = to_sentence (string)

Class#

Elemental function.

Argument#

string: shall be an intrinsic character type. It is an intent(in) argument.

Result value#

The result is an intrinsic character type of the same length as string.

Example#

program example_to_sentence
  use stdlib_ascii, only: to_sentence
  implicit none
  print *, to_sentence("hello!") ! returns "Hello!"
  print *, to_sentence("'enquoted'") ! returns "'Enquoted'"
  print *, to_sentence("1st")  ! returns "1st"
end program example_to_sentence

reverse#

Status#

Experimental

Description#

Reverses the order of all characters in the input character type.

Syntax#

res = reverse (string)

Class#

Elemental function.

Argument#

string: shall be an intrinsic character type. It is an intent(in) argument.

Result value#

The result is an intrinsic character type of the same length as string.

Example#

program example_reverse
  use stdlib_ascii, only: reverse
  implicit none
  print'(a)', reverse("Hello, World!") ! returns "!dlroW ,olleH"
end program example_reverse