Copyright | (c) 2020-2021 Sam May |
---|---|
License | GPL-3.0-or-later |
Maintainer | ag@eitilt.life |
Stability | stable |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
The CdText standard technically allows for data encoded as Shift JIS; I am unaware of any discs produced with such data as no member of the libcdio-dev mailing list (or any of the very few other resources) have Japanese imports, but for completion the ability to read that encoding is required. This module provides a light-weight implementation modeled on the Data.Text.Encoding UTF-8 interface.
Synopsis
- data JISChar
- data JISDecodeError = JISDecodeError String (Maybe JISChar)
- data JISEncodeError = JISEncodeError String (Maybe Char)
- decodeMsJIS' :: ByteString -> Either JISDecodeError Text
- decodeMsJISWith :: OnError JISChar Char -> ByteString -> Text
- encodeMsJIS' :: Text -> Either JISEncodeError ByteString
- encodeMsJISWith :: OnError Char ByteString -> Text -> ByteString
Types
The characters which may be represented under the Shift JIS encoding.
Note that this type is only exposed as part of error reporting or recovery
functions, and is not intended as a replacement of Char
.
Instances
Bounded JISChar Source # | |
Enum JISChar Source # | Ignores the three invalid single-byte characters
|
Eq JISChar Source # | |
Ord JISChar Source # | |
Read JISChar Source # | |
Show JISChar Source # | |
data JISDecodeError Source #
The given one- or two- byte sequence was unable to be decoded; the error may be described by the unstructured text.
Instances
Eq JISDecodeError Source # | |
Defined in Data.Text.Encoding.MsJIS (==) :: JISDecodeError -> JISDecodeError -> Bool # (/=) :: JISDecodeError -> JISDecodeError -> Bool # | |
Read JISDecodeError Source # | |
Defined in Data.Text.Encoding.MsJIS readsPrec :: Int -> ReadS JISDecodeError # readList :: ReadS [JISDecodeError] # | |
Show JISDecodeError Source # | |
Defined in Data.Text.Encoding.MsJIS showsPrec :: Int -> JISDecodeError -> ShowS # show :: JISDecodeError -> String # showList :: [JISDecodeError] -> ShowS # |
data JISEncodeError Source #
The given character was unable to be serialized in binary form; this is almost certainly due to it not being included in Shift JIS, but the error is described by the unstructured text anyway.
Instances
Eq JISEncodeError Source # | |
Defined in Data.Text.Encoding.MsJIS (==) :: JISEncodeError -> JISEncodeError -> Bool # (/=) :: JISEncodeError -> JISEncodeError -> Bool # | |
Read JISEncodeError Source # | |
Defined in Data.Text.Encoding.MsJIS readsPrec :: Int -> ReadS JISEncodeError # readList :: ReadS [JISEncodeError] # | |
Show JISEncodeError Source # | |
Defined in Data.Text.Encoding.MsJIS showsPrec :: Int -> JISEncodeError -> ShowS # show :: JISEncodeError -> String # showList :: [JISEncodeError] -> ShowS # |
Transformations
Decode
decodeMsJIS' :: ByteString -> Either JISDecodeError Text Source #
Transform a ByteString
into unambiguous Char
s according to
Microsoft's extension of the Shift JIS encoding scheme.
If the input contains any invalid sequences under that scheme, the first byte(s) which triggered an error will be returned instead.
decodeMsJISWith :: OnError JISChar Char -> ByteString -> Text Source #
Transform a ByteString
into unambiguous Char
s according to
Microsoft's extension of the Shift JIS encoding scheme.
Encode
encodeMsJIS' :: Text -> Either JISEncodeError ByteString Source #
Transform an unambiguous string into a binary stream according to Microsoft's extension of the Shift JIS encoding scheme.
If the input contains any characters without an associated binary sequence under that scheme, the first such character which triggers the error will be returned instead.
encodeMsJISWith :: OnError Char ByteString -> Text -> ByteString Source #
Transform an unambiguous string into a binary stream according to Microsoft's extension of the Shift JIS encoding scheme.