Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Implementation of Double-X-Encoding encoder and decoder in Haskell
Main functions:
Synopsis
- charEncode :: Char -> Char
- charDecode :: Char -> Char
- hexShiftEncode :: Char -> Char
- hexShiftDecode :: Char -> Char
- data EncodeOptions = EncodeOptions {}
- doubleXEncodeWithOptions :: EncodeOptions -> Text -> Text
- defaultOptions :: EncodeOptions
- doubleXEncode :: Text -> Text
- gqlOptions :: EncodeOptions
- doubleXEncodeGql :: Text -> Text
- doubleXDecode :: Text -> Text
Documentation
charEncode :: Char -> Char Source #
Encoder mapping for ASCII characters.
charDecode :: Char -> Char Source #
Decoder mapping for ASCII characters.
hexShiftEncode :: Char -> Char Source #
Map hex characters to an alternative hex alphabet ranging from a to p instead of 0 to f.
hexShiftDecode :: Char -> Char Source #
Map alternative hex alphabet back to the original hex alphabet.
data EncodeOptions Source #
Options for encoding:
encodeLeadingDigit
- Encode the leading digit of the input string
encodeDoubleUnderscore
- Encode double underscores
__
asXXRXXR
Especially relevant for GraphQL, as the spec does not allow leading digits or double underscores for field names.
doubleXEncodeWithOptions :: EncodeOptions -> Text -> Text Source #
Encode a text using the Double-X-Encoding algorithm with provided options.
defaultOptions :: EncodeOptions Source #
Default options with no leading digit encoding and no double underscore encoding.
doubleXEncode :: Text -> Text Source #
Encode a text using the Double-X-Encoding algorithm.
>>>
doubleXEncode "id-with.special$chars!"
"idXXDwithXXEspecialXX4charsXX1"
gqlOptions :: EncodeOptions Source #
Default options for GraphQL encoding. Leading digits or double underscores are not allowed for field names.
doubleXEncodeGql :: Text -> Text Source #
Encode a text using the Double-X-Encoding algorithm with GraphQL options.
>>>
doubleXEncodeGql "1FileFormat__"
"XXZ1FileFormatXXRXXR"
doubleXDecode :: Text -> Text Source #
Decode a Double-X-Encoding encoded text.
>>>
doubleXDecode "idXXDwithXXEspecialXX4charsXX1"
"id-with.special$chars!"