W3cubDocs

/Haskell 7

GHC.IO.Encoding.Failure

Copyright (c) The University of Glasgow, 2008-2011
License see libraries/base/LICENSE
Maintainer [email protected]
Stability internal
Portability non-portable
Safe Haskell Trustworthy
Language Haskell2010

Description

Types for specifying how text encoding/decoding fails

data CodingFailureMode Source

The CodingFailureMode is used to construct TextEncodings, and specifies how they handle illegal sequences.

Constructors

ErrorOnCodingFailure

Throw an error when an illegal sequence is encountered

IgnoreCodingFailure

Attempt to ignore and recover if an illegal sequence is encountered

TransliterateCodingFailure

Replace with the closest visual match upon an illegal sequence

RoundtripFailure

Use the private-use escape mechanism to attempt to allow illegal sequences to be roundtripped.

codingFailureModeSuffix :: CodingFailureMode -> String Source

isSurrogate :: Char -> Bool Source

Some characters are actually "surrogate" codepoints defined for use in UTF-16. We need to signal an invalid character if we detect them when encoding a sequence of Chars into Word8s because they won't give valid Unicode.

We may also need to signal an invalid character if we detect them when encoding a sequence of Chars into Word8s because the RoundtripFailure mode creates these to round-trip bytes through our internal UTF-16 encoding.

recoverDecode :: CodingFailureMode -> Buffer Word8 -> Buffer Char -> IO (Buffer Word8, Buffer Char) Source

recoverEncode :: CodingFailureMode -> Buffer Char -> Buffer Word8 -> IO (Buffer Char, Buffer Word8) Source

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/7.10.3/docs/html/libraries/base-4.8.2.0/GHC-IO-Encoding-Failure.html