hex
Function
hex — encode/decode hexadecimal strings
Synopsis
hex(b: bytes) -> string
hex(s: string) -> bytes
Description
The hex function encodes a bytes value b
as
a hexadecimal string or decodes a hexadecimal string s
into a bytes value.
Examples
Encode a simple bytes sequence as a hexadecimal string:
yield hex(this)
0x0102ff
Loading...
echo '0x0102ff' \
| super -z -c 'yield hex(this)' -
Decode a simple hex string:
yield hex(this)
"0102ff"
Loading...
echo '"0102ff"' \
| super -z -c 'yield hex(this)' -
Encode the bytes of an ASCII string as a hexadecimal string:
yield hex(bytes(this))
"hello, world"
Loading...
echo '"hello, world"' \
| super -z -c 'yield hex(bytes(this))' -
Decode hex string representing ASCII into its string form:
yield string(hex(this))
"68656c6c6f20776f726c64"
Loading...
echo '"68656c6c6f20776f726c64"' \
| super -z -c 'yield string(hex(this))' -