Z-Data-0.9.0.0: Array, vector and text
Copyright(c) Dong Han 2017-2018
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.Data.Vector.Hex

Description

This module provides hex encoding & decoding tools, as well as HexBytes newtype with hex textual instances.

Synopsis

The HexBytes type

newtype HexBytes Source #

New type wrapper for Bytes with hex encoding(uppercase) Show/JSON instances.

Constructors

HexBytes 

Fields

Instances

Instances details
Eq HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

Ord HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

Show HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

Semigroup HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

Monoid HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

Hashable HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

Methods

hashWithSalt :: Int -> HexBytes -> Int #

hash :: HexBytes -> Int #

Print HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

JSON HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

Encoding & Decoding functions

hexEncode Source #

Arguments

:: Bool

uppercase?

-> Bytes 
-> Bytes 

Encode Bytes using hex(base16) encoding.

hexEncodeText Source #

Arguments

:: Bool

uppercase?

-> Bytes 
-> Text 

Text version of hexEncode.

hexEncodeBuilder Source #

Arguments

:: Bool

uppercase?

-> Bytes 
-> Builder () 

Builder version of hexEncode.

hexDecode :: Bytes -> Maybe Bytes Source #

Decode a hex encoding string, return Nothing on illegal bytes or incomplete input.

hexDecode' :: HasCallStack => Bytes -> Bytes Source #

Decode a hex encoding string, throw HexDecodeException on error.

hexDecodeWS :: Bytes -> Maybe Bytes Source #

Decode a hex encoding string, ignore ASCII whitespace(space, tab, newline, vertical tab, form feed, carriage return).

This is useful when you get some hex nibbles by pasting from web, note only whitesapces between bytes(two nibbles) are allowed:

>>> hexDecodeWS "6f7481 da0e53"
Just [111,116,129,218,14,83]
>>> hexDecodeWS "6f7481d a0e53"
Nothing

hexDecodeWS' :: HasCallStack => Bytes -> Bytes Source #

Decode a hex encoding string, ignore ASCII whitespace(space, tab, newline, vertical tab, form feed, carriage return), throw HexDecodeException on error.

Internal C FFIs