-
Notifications
You must be signed in to change notification settings - Fork 11
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
hexto 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
outputis NULL, this function ignoresoutput_sizeand returns the necessary size to store the entire decoded data fromhex. If the data inhexis not a multiple of two characters, this will return-1instead. However, no further checking of the input is done in this mode.If
outputis not NULL, this will convert the hexadecimal string data inhex(upper or lower case) and write it tooutput. Ifoutput_sizeis too small for the entire conversion, or if any part of the conversion fails, this will return-1andoutputwill 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
sizebytes ofdatato a lower-case hexadecimal string representation. Ifsizeis0,datamay be NULL; otherwise,datamust be non-NULL. - Encode all data stored in
datato a lower-case hexadecimal string representation.