Operations on character values.
The CHAR signature defines a type char of characters, and provides basic operations and predicates on values of that type. There is a linear ordering defined on characters. In addition, there is an encoding of characters into a contiguous range of non-negative integers which preserves the linear ordering. There are two structures matching the CHAR signature. The Char structure provides the extended ASCII 8-bit character set and locale-independent operations on them. For this structure, Char.maxOrd = 255.structure Char : CHAR
signature CHAR = sig eqtype char eqtype string val minChar : char val maxChar : char val maxOrd : int val ord : char -> int val chr : int -> char val succ : char -> char val pred : char -> char val compare : char * char -> order val < : char * char -> bool val <= : char * char -> bool val > : char * char -> bool val >= : char * char -> bool val contains : string -> char -> bool val notContains : string -> char -> bool val isAscii : char -> bool val toLower : char -> char val toUpper : char -> char val isAlpha : char -> bool val isAlphaNum : char -> bool val isCntrl : char -> bool val isDigit : char -> bool val isGraph : char -> bool val isHexDigit : char -> bool val isLower : char -> bool val isPrint : char -> bool val isSpace : char -> bool val isPunct : char -> bool val isUpper : char -> bool val toString : char -> String.string val scan : (Char.char, 'a) StringCvt.reader -> (char, 'a) StringCvt.reader val fromString : String.string -> char option val toCString : char -> String.string val fromCString : String.string -> char option end
Alert (ASCII 0x07) "\\a" Backspace (ASCII 0x08) "\\b" Horizontal tab (ASCII 0x09) "\\t" Linefeed or newline (ASCII 0x0A) "\\n" Vertical tab (ASCII 0x0B) "\\v" Form feed (ASCII 0x0C) "\\f"The remaining characters whose codes are less than 32 are represented by three-character strings in ``control character'' notation, e.g., #"\000" maps to "\\^@", #"\001" maps to "\\^A", etc. For characters whose codes are greater than 999, the character is mapped to a six-character string of the form "\\uxxxx", where xxxx are the four hexadecimal digits corresponding to a character's code. All other characters (i.e., those whose codes are greater than 126 but less than 1000) are mapped to four-character strings of the form "\\ddd", where ddd are the three decimal digits corresponding to a character's code. To convert a character to a length-one string containing the character, use the function String.str.
\a Alert (ASCII 0x07) \b Backspace (ASCII 0x08) \t Horizontal tab (ASCII 0x09) \n Linefeed or newline (ASCII 0x0A) \v Vertical tab (ASCII 0x0B) \f Form feed (ASCII 0x0C) \r Carriage return (ASCII 0x0D) \\ Backslash \" Double quote \^c A control character whose encoding is ord c - 64, with the character c having ord c in the range [64,95]. For example, \^H (control-H) is the same as \b (backspace). \ddd The character whose encoding is the number ddd, three decimal digits denoting an integer in the range [0,255]. \uxxxx The character whose encoding is the number xxxx, four hexadecimal digits denoting an integer in the ordinal range of the alphabet. \f...f\ This sequence is ignored, where f...f stands for a sequence of one or more formatting (space, newline, tab, etc.)In the escape sequences involving decimal or hexadecimal digits, if the resulting value cannot be represented in the character set, NONE is returned. As the table indicates, escaped formatting sequences (\f...f\) are passed over during scanning. Such sequences are successfully scanned, so that the remaining stream returned by scan will never have a valid escaped formatting sequence as its prefix. Here are some sample conversions:
Input string s fromString s "\\q" NONE "a\^D" SOME #"a" "a\\ \\\q" SOME #"a" "\\ \\" NONE "" NONE "\\ \\\^D" NONE
Alert (ASCII 0x07) "\\a" Backspace (ASCII 0x08) "\\b" Horizontal tab (ASCII 0x09) "\\t" Linefeed or newline (ASCII 0x0A) "\\n" Vertical tab (ASCII 0x0B) "\\v" Form feed (ASCII 0x0C) "\\f"All other characters are represented by three octal digits, corresponding to a character's code, preceded by a backslash.
\a Alert (ASCII 0x07) \b Backspace (ASCII 0x08) \t Horizontal tab (ASCII 0x09) \n Linefeed or newline (ASCII 0x0A) \v Vertical tab (ASCII 0x0B) \f Form feed (ASCII 0x0C) \r Carriage return (ASCII 0x0D) \? Question mark \\ Backslash \" Double quote \' Single quote \^c A control character whose encoding is ord c - 64, with the character c having ord c in the range [64,95]. For example, \^H (control-H) is the same as \b (backspace). \ooo The character whose encoding is the number ooo, where ooo consists of one to three octal digits \xhh The character whose encoding is the number hh, where hh is aNote that fromCString accepts an unescaped single quote character, but does not accept an unescaped double quote character. In the escape sequences involving octal or hexadecimal digits, the sequence of digits is taken to be the longest sequence of such characters. If the resulting value cannot be represented in the character set, NONE is returned.