text-latin1-0.3: Latin-1 (including ASCII) utility functions

Safe HaskellNone

Text.Ascii

Contents

Description

ASCII utility functions.

Synopsis

ASCII checks

maybeAscii :: Char -> Maybe Word8Source

Map a character to its ASCII encoding if possible, otherwise return Nothing.

ascii :: Char -> Word8Source

Encode an ASCII character. No checks are performed.

Character properties

isControl :: Char -> BoolSource

Test if a character is an ASCII control character.

isPrintable :: Char -> BoolSource

Test if a character is an ASCII printable character.

isWhiteSpace :: Char -> BoolSource

Test if a character is an ASCII whitespace character.

isSpaceOrTab :: Char -> BoolSource

Test if a character is the SPACE or the TAB character.

isLower :: Char -> BoolSource

Test if a character is an ASCII lower-case letter.

isUpper :: Char -> BoolSource

Test if a character is an ASCII upper-case letter.

toLower :: Char -> CharSource

Map lower-case ASCII letters to the corresponding upper-case letters, leaving other characters as is.

toUpper :: Char -> CharSource

Map upper-case ASCII letters to the corresponding lower-case letters, leaving other characters as is.

isAlpha :: Char -> BoolSource

Test if a character is an ASCII letter.

isAlphaNum :: Char -> BoolSource

Test if a character is either an ASCII letter or a decimal digit.

isDecDigit :: Char -> BoolSource

Test if a character is a decimal digit ('0' ... '9').

isNzDecDigit :: Char -> BoolSource

Test if a character is a non-zero decimal digit ('1' ... '9').

fromDecDigit :: Num a => Char -> Maybe aSource

Map a decimal digit to the corresponding number. Return Nothing on other inputs.

fromNzDecDigit :: Num a => Char -> Maybe aSource

Map non-zero decimal digits to the corresponding numbers. Return Nothing on other inputs.

unsafeFromDecDigit :: Num a => Char -> aSource

Map decimal digits to the corresponding numbers. No checks are performed.

isBinDigit :: Char -> BoolSource

Test if a character is a binary digit ('0' or '1').

isNzBinDigit :: Char -> BoolSource

Test if a character is the non-zero binary digit ('1').

fromBinDigit :: Num a => Char -> Maybe aSource

Map binary digits to the corresponding numbers. Return Nothing on other inputs.

fromNzBinDigit :: Num a => Char -> Maybe aSource

Map the digit '1' to the number 1. Return Nothing on other inputs.

unsafeFromBinDigit :: Num a => Char -> aSource

Map binary digits to the corresponding numbers. No checks are performed.

isOctDigit :: Char -> BoolSource

Test if a character is an octal digit ('0' ... '7').

isNzOctDigit :: Char -> BoolSource

Test if a character is a non-zero octal digit ('1' ... '7').

fromOctDigit :: Num a => Char -> Maybe aSource

Map octal digits to the corresponding numbers. Return Nothing on other inputs.

fromNzOctDigit :: Num a => Char -> Maybe aSource

Map non-zero octal digits to the corresponding numbers. Return Nothing on other inputs.

unsafeFromOctDigit :: Num a => Char -> aSource

Map octal digits to the corresponding numbers. No checks are performed.

isUpHexDigit :: Char -> BoolSource

Test if a character is an upper-case hexadecimal digit ('0' ... '9' or 'A' ... 'F').

isNzUpHexDigit :: Char -> BoolSource

Test if a character is a non-zero upper-case hexadecimal digit ('1' ... '9' or 'A' ... 'F').

fromUpHexDigit :: Num a => Char -> Maybe aSource

Map upper-case hexadecimal digits to the corresponding numbers. Return Nothing on other inputs.

fromNzUpHexDigit :: Num a => Char -> Maybe aSource

Map non-zero upper-case hexadecimal digits to the corresponding numbers. Return Nothing on other inputs.

unsafeFromUpHexDigit :: Num a => Char -> aSource

Map upper-case hexadecimal digits to the corresponding numbers. No checks are performed.

isLowHexDigit :: Char -> BoolSource

Test if a character is a lower-case hexadecimal digit ('0' ... '9' or 'a' ... 'f').

isNzLowHexDigit :: Char -> BoolSource

Test if a character is a non-zero lower-case hexadecimal digit ('1' ... '9' or 'a' ... 'f').

fromLowHexDigit :: Num a => Char -> Maybe aSource

Map lower-case hexadecimal digits to the corresponding numbers. Return Nothing on other inputs.

fromNzLowHexDigit :: Num a => Char -> Maybe aSource

Map non-zero lower-case hexadecimal digits to the corresponding numbers. Return Nothing on other inputs.

unsafeFromLowHexDigit :: Num a => Char -> aSource

Map lower-case hexadecimal digits to the corresponding numbers. No checks are performed.

isHexDigit :: Char -> BoolSource

Test if a character is a hexadecimal digit ('0' ... '9' or 'a' ... 'f' or 'A' ... 'F').

isNzHexDigit :: Char -> BoolSource

Test if a character is a non-zero hexadecimal digit ('1' ... '9' or 'a' ... 'f' or 'A' ... 'F').

fromHexDigit :: Num a => Char -> Maybe aSource

Map hexadecimal digits to the corresponding numbers. Return Nothing on other inputs.

fromNzHexDigit :: Num a => Char -> Maybe aSource

Map non-zero hexadecimal digits to the corresponding numbers. Return Nothing on other inputs.

unsafeFromHexDigit :: Num a => Char -> aSource

Map hexadecimal digits to the corresponding numbers. No checks are performed.

Byte properties

isControl8 :: Word8 -> BoolSource

Test if a byte is the encoding of an ASCII control character.

isPrintable8 :: Word8 -> BoolSource

Test if a byte is the encoding of an ASCII printable character.

isWhiteSpace8 :: Word8 -> BoolSource

Test if a byte is the encoding of an ASCII whitespace character.

isSpaceOrTab8 :: Word8 -> BoolSource

Test if a byte is the encoding of the SPACE or the TAB character.

isLower8 :: Word8 -> BoolSource

Test if a byte is the encoding of an ASCII lower-case letter.

isUpper8 :: Word8 -> BoolSource

Test if a byte is the encoding of an ASCII upper-case letter.

toLower8 :: Word8 -> Word8Source

Map the encodings of lower-case ASCII letters to the encodings of the corresponding upper-case letters, leaving other bytes as is.

toUpper8 :: Word8 -> Word8Source

Map the encodings of upper-case ASCII letters to the encodings of the corresponding lower-case letters, leaving other bytes as is.

isAlpha8 :: Word8 -> BoolSource

Test if a byte is the encoding of an ASCII letter.

isAlphaNum8 :: Word8 -> BoolSource

Test if a byte is the encoding of either an ASCII letter or a decimal digit.

isDecDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a decimal digit ('0' ... '9').

isNzDecDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a non-zero decimal digit ('1' ... '9').

fromDecDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a decimal digit to the corresponding number. Return Nothing on other inputs.

fromNzDecDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a non-zero decimal digit to the corresponding number. Return Nothing on other inputs.

unsafeFromDecDigit8 :: Num a => Word8 -> aSource

Map the encoding of a decimal digit to the corresponding number. No checks are performed.

isBinDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a binary digit ('0' or '1').

isNzBinDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of the non-zero binary digit ('1').

fromBinDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a binary digit to the corresponding number. Return Nothing on other inputs.

fromNzBinDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of the digit '1' to the number 1. Return Nothing on other inputs.

unsafeFromBinDigit8 :: Num a => Word8 -> aSource

Map the encoding of a binary digit to the corresponding number. No checks are performed.

isOctDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of an octal digit ('0' ... '7').

isNzOctDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a non-zero octal digit ('1' ... '7').

fromOctDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of an octal digit to the corresponding number. Return Nothing on other inputs.

fromNzOctDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a non-zero octal digit to the corresponding number. Return Nothing on other inputs.

unsafeFromOctDigit8 :: Num a => Word8 -> aSource

Map the encoding of an octal digit to the corresponding number. No checks are performed.

isUpHexDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of an upper-case hexadecimal digit ('0' ... '9' or 'A' ... 'F').

isNzUpHexDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a non-zero upper-case hexadecimal digit ('1' ... '9' or 'A' ... 'F').

fromUpHexDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of an upper-case hexadecimal digit to the corresponding number. Return Nothing on other inputs.

fromNzUpHexDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a non-zero upper-case hexadecimal digit to the corresponding number. Return Nothing on other inputs.

unsafeFromUpHexDigit8 :: Num a => Word8 -> aSource

Map the encoding of an upper-case hexadecimal digit to the corresponding number. No checks are performed.

isLowHexDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a lower-case hexadecimal digit ('0' ... '9' or 'a' ... 'f').

isNzLowHexDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a non-zero lower-case hexadecimal digit ('1' ... '9' or 'a' ... 'f').

fromLowHexDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a lower-case hexadecimal digit to the corresponding number. Return Nothing on other inputs.

fromNzLowHexDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a non-zero lower-case hexadecimal digit to the corresponding number. Return Nothing on other inputs.

unsafeFromLowHexDigit8 :: Num a => Word8 -> aSource

Map the encoding of a lower-case hexadecimal digit to the corresponding number. No checks are performed.

isHexDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a hexadecimal digit ('0' ... '9' or 'a' ... 'f' or 'A' ... 'F').

isNzHexDigit8 :: Word8 -> BoolSource

Test if a byte is the encoding of a non-zero hexadecimal digit ('1' ... '9' or 'a' ... 'f' or 'A' ... 'F').

fromHexDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a hexadecimal digit to the corresponding number. Return Nothing on other inputs.

fromNzHexDigit8 :: Num a => Word8 -> Maybe aSource

Map the encoding of a non-zero hexadecimal digit to the corresponding number. Return Nothing on other inputs.

unsafeFromHexDigit8 :: Num a => Word8 -> aSource

Map the encoding of a hexadecimal digit to the corresponding number. No checks are performed.