binary-parsers-0.2.1.0: Extends binary with parsec/attoparsec style parsing combinators.

CopyrightBryan O'Sullivan 2007-2015, Winterland 2016
LicenseBSD3
Maintainerdrkoster@qq.com
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Data.Binary.Parser.Char8

Description

This module is intended for parsing text that is represented using an 8-bit character set, e.g. ASCII or ISO-8859-15. It does not make any attempt to deal with character encodings, multibyte characters, or wide characters. In particular, all attempts to use characters above code point U+00FF will give wrong answers.

Code points below U+0100 are simply translated to and from their numeric values, so e.g. the code point U+00A4 becomes the byte 0xA4 (which is the Euro symbol in ISO-8859-15, but the generic currency sign in ISO-8859-1). Haskell Char values above U+00FF are truncated, so e.g. U+1D6B7 is truncated to the byte 0xB7.

Synopsis

Documentation

peekMaybe :: Get (Maybe Char) Source #

Match any char, to perform lookahead. Returns Nothing if end of input has been reached. Does not consume any input.

peek :: Get Char Source #

Match any char, to perform lookahead. Does not consume any input, but will fail if end of input has been reached.

satisfy :: (Char -> Bool) -> Get Char Source #

The parser satisfy p succeeds for any char for which the predicate p returns True. Returns the char that is actually parsed.

satisfyWith :: (Char -> a) -> (a -> Bool) -> Get a Source #

The parser satisfyWith f p transforms a char, and succeeds if the predicate p returns True on the transformed value. The parser returns the transformed char that was parsed.

char :: Char -> Get () Source #

Match a specific character.

anyChar :: Get Char Source #

Match any character.

skipChar :: (Char -> Bool) -> Get () Source #

The parser skipChar p succeeds for any char for which the predicate p returns True.

takeTill :: (Char -> Bool) -> Get ByteString Source #

Consume input as long as the predicate returns False or reach the end of input, and return the consumed input.

takeWhile :: (Char -> Bool) -> Get ByteString Source #

Consume input as long as the predicate returns True or reach the end of input, and return the consumed input.

skipWhile :: (Char -> Bool) -> Get () Source #

Skip past input for as long as the predicate returns True.

stringCI :: ByteString -> Get ByteString Source #

Satisfy a literal string but ignoring case.

isSpace :: Char -> Bool Source #

Fast predicate for matching ASCII space characters.

Note: This predicate only gives correct answers for the ASCII encoding. For instance, it does not recognise U+00A0 (non-breaking space) as a space character, even though it is a valid ISO-8859-15 byte. For a Unicode-aware and only slightly slower predicate, use isSpace

isDigit :: Char -> Bool Source #

Decimal digit predicate.

isHexDigit :: Char -> Bool Source #

Hex digit predicate.

isHorizontalSpace :: Char -> Bool Source #

A predicate that matches either a space ' ' or horizontal tab '\t' character.

isEndOfLine :: Char -> Bool Source #

A predicate that matches either a carriage return '\r' or newline '\n' character.