ascii
The ASCII character set and encoding
https://github.com/typeclasses/ascii
| Version on this page: | 1.2.5.0 |
| LTS Haskell 22.44: | 1.7.0.2 |
| Stackage Nightly 2023-12-26: | 1.7.0.1 |
| Latest on Hackage: | 1.7.0.2 |
ascii-1.2.5.0@sha256:e9ce4c32f235b3481242d12a916d8dbdb43fd568d4cde59950f1025e7df4b95c,2124Module documentation for 1.2.5.0
What is ASCII?
The American Standard Code for Information Interchange (ASCII) comprises a set of 128 characters, each represented by 7 bits. 33 of these characters are “control codes”; a few of these are still in use, but most are obsolete relics of the early days of computing. The other 95 are “printable characters” such as letters and numbers, mostly corresponding to the keys on an American English keyboard.
Nowadays instead of ASCII we typically work with text using an encoding such as UTF-8 that can represent the entire Unicode character set, which includes over a hundred thousand characters and is not limited to the symbols of any particular writing system or culture. However, ASCII is still relevant to network protocols; for example, we can see it in the specification of HTTP message headers.
There is a convenient relationship between ASCII and Unicode: the ASCII characters are the first 128 characters of the much larger Unicode character set. The C0 Controls and Basic Latin section of the Unicode standard contains a list of all the ASCII characters.
Haskell packages
This repository contains the main API, the ASCII module in the
ascii package, which is an amalgamation of smaller packages in other
repositories.
-
If you only need the ASCII
Chartype, you can use theascii-charpackage, which is minimal so that it can be kept stable. -
The
ascii-grouppackage defines theGrouptype (ControlandPrintable), and theascii-casepackage defines theCasetype (UpperCaseandLowerCase). These package are also small and stable. -
The
ascii-predicatespackage provides additional ways of categorizing characters similar to what you can find in thebasepackage. -
For case-insensitivity, use the
ascii-caselesspackage. -
The
ascii-supersetpackage definesCharSupersetandStringSupersetclasses to generalize types that represent characters and strings, respectively, in character sets larger than ASCII. It also defines theASCIItype constructor, which is used to indicate that a value from some ASCII superset is confined to ASCII. -
The
ascii-numberspackage provides utilities for working with numbers represented using ASCII digits 0-9, ASCII letters A-F to represent hexadecimal digits 10-15, and theHypenMinuscharacter for negation. -
The
ascii-thpackage provides a quasi-quoter that allows one to safely and conveniently express ASCII string literals. The generated expressions are polymorphic and can take the form of any type belonging to theStringSupersetclass, including[ASCII.Char],String,ByteString, andText.
Changes
1.2.5.0 (2022-01-02)
Add the ASCII.Caseless module (re-exported from the ascii-caseless package)
Additions to the ASCII module:
CaselessChar
1.2.4.1 (2022-12-30)
Metadata changes only
1.2.4.0 (2022-12-23)
Bump version of ascii-case to 1.0.1. This adds the following function to the
ASCII.Case module:
opposite :: Case -> Case
1.2.3.0 (2022-05-04)
Add isVisible :: Char -> Bool. Visible characters include all print characters
other than Space.
1.2.2.0 (2022-04-29)
Add type UnicodeChar = Data.Char.Char type alias to ASCII module
1.2.1.0 (2022-04-29)
New polymorphic narrowing functions:
toAsciiCharMaybe :: CharSuperset char => char -> Maybe ChartoDigitMaybe :: DigitSuperset char => char -> Maybe DigittoHexCharMaybe :: HexCharSuperset char => char -> Maybe HexChar
New monomorphic character conversion functions:
digitToWord8 :: Digit -> Word8word8ToDigitMaybe :: Word8 -> Maybe Digitword8ToDigitUnsafe :: Word8 -> DigitdigitToChar :: Digit -> CharcharToDigitMaybe :: Char -> Maybe DigitcharToDigitUnsafe :: Char -> DigitdigitToUnicode :: Digit -> Unicode.CharunicodeToDigitMaybe :: Unicode.Char -> Maybe DigitunicodeToDigitUnsafe :: Unicode.Char -> DigithexCharToWord8 :: HexChar -> Word8word8ToHexCharMaybe :: Word8 -> Maybe HexCharword8ToHexCharUnsafe :: Word8 -> HexCharhexCharToChar :: HexChar -> CharcharToHexCharMaybe :: Char -> Maybe HexCharcharToHexCharUnsafe :: Char -> HexCharhexCharToUnicode :: HexChar -> Unicode.CharunicodeToHexCharMaybe :: Unicode.Char -> Maybe HexCharunicodeToHexCharUnsafe :: Unicode.Char -> HexChar
1.2.0.0 (2022-04-20)
Update to ascii-numbers version 1.1.0. The major change is that there are
now Lift instances for Digit and HexChar.
1.1.3.0
Added functions digitString and hexCharString
1.1.2.0
Add dependency on ascii-numbers
New modules:
ASCII.DecimalASCII.Hexadecimal
New types:
DigitHexChar
New classes:
DigitSupersetDigitStringSupersetHexCharSupersetHexStringSuperset
New functions:
-
showIntegralDecimal -
showIntegralHexadecimal -
readIntegralDecimal -
readIntegralHexadecimal -
showNaturalDigits -
readNaturalDigits -
showNaturalHexChars -
readNaturalHexChars -
showNaturalDecimal -
showNaturalHexadecimal -
readNaturalDecimal -
readNaturalHexadecimal
Dropped support for old versions:
- Drop support for
base4.11 (GHC 8.4) - Drop support for
base4.12 (GHC 8.6)
1.1.1.4
Switch test-suite over to hedgehog
1.1.1.2
Support GHC 9.2
1.1.1.0
New functions:
isAlphaNumisLetterisDigitisOctDigitisHexDigitisSpaceisPunctuationisSymbol
1.1.0.0
The dependency on the ‘data-ascii’ package is removed, and the following modules are no longer re-exported:
Data.AsciiData.Ascii.BlazeData.Ascii.ByteStringData.Ascii.Word8
1.0.1.6
Add a test suite
Raise text lower bound to 1.2.3
1.0.1.4
Support GHC 9.0
1.0.1.2
Support bytestring-0.11
1.0.1.0
New functions:
byteStringToUnicodeStringMaybeunicodeStringToByteStringMaybebyteListToUnicodeStringMaybeunicodeStringToByteListMaybeconvertCharMaybeconvertCharOrFailconvertStringMaybeconvertStringOrFail
1.0.0.2
Support GHC 8.10
1.0.0.0
Completely redesigned the library