-
Notifications
You must be signed in to change notification settings - Fork 12
ST::hex
#include <string_theory/codecs>
Name | Summary |
---|---|
ST::hex_encode | Encode a sequence of bytes as hex |
ST::hex_decode | Decode a hex string into a sequence of bytes |
Signature | |
---|---|
ST::char_buffer ST::hex_decode(const ST::string &hex) | (1) |
ST_ssize_t ST::hex_decode(const ST::string &hex, void *output, size_t output_size) noexcept | (2) |
-
Decode the hexadecimal string (upper or lower case) in
hex
to a buffer. If the input string contains invalid hex data, an ST::codec_error is thrown with a message indicating the type of failure. -
If
output
is NULL, this function ignoresoutput_size
and returns the necessary size to store the entire decoded data fromhex
. If the data inhex
is not a multiple of two characters, this will return-1
instead. However, no further checking of the input is done in this mode.If
output
is not NULL, this will convert the hexadecimal string data inhex
(upper or lower case) and write it tooutput
. Ifoutput_size
is too small for the entire conversion, or if any part of the conversion fails, this will return-1
andoutput
will be left in an indeterminate state.
Signature | |
---|---|
ST::string ST::hex_encode(const void *data, size_t size) | (1) |
ST::string ST::hex_encode(const ST::char_buffer &data) | (2) |
- Encode the first
size
bytes ofdata
to a lower-case hexadecimal string representation. Ifsize
is0
,data
may be NULL; otherwise,data
must be non-NULL. - Encode all data stored in
data
to a lower-case hexadecimal string representation.