unwitch-3.0.0: converts between primitives
Safe HaskellNone
LanguageHaskell2010

Unwitch.Convert.Char

Description

Conversions from Char.

Synopsis

Conversions

toInt :: Char -> Int Source #

Converts a Char to its Unicode codepoint as Int. Infallible.

toWord :: Char -> Word Source #

Converts a Char to its Unicode codepoint as Word. Infallible.

fromInt :: Int -> Maybe Char Source #

Converts an Int to a Char if it is a valid Unicode codepoint. Valid range: 0..0xD7FF and 0xE000..0x10FFFF (excludes surrogates).

fromWord :: Word -> Maybe Char Source #

Converts a Word to a Char if it is a valid Unicode codepoint. Valid range: 0..0xD7FF and 0xE000..0x10FFFF (excludes surrogates).

Unboxed conversions

These use GHC unboxed types and unboxed sums for zero-allocation failure handling. Requires the MagicHash, UnboxedSums and UnboxedTuples language extensions. See the GHC manual on unboxed types.

fromInt# :: Int -> (# Char | (# #) #) Source #

Unboxed variant of fromInt. Checks valid Unicode codepoint range.

fromWord# :: Word -> (# Char | (# #) #) Source #

Unboxed variant of fromWord. Checks valid Unicode codepoint range.