hexBinary

A hexBinary is arbitrary binary data in hexadecimal encoding.

Strings consist of an even number of hexadecimal characters ([0-9], [A-F], and [a-f]). Note that, unlike base64Binary, whitespace between characters isn’t allowed.

size_t exess_decoded_hex_size(size_t length)

Return the maximum number of bytes required to decode length bytes of hex.

The returned value is an upper bound which is only exact for canonical strings.

Parameters:
  • length – Number of input (text) bytes to decode.

Returns:

The size of a decoded value in bytes.

ExessVariableResult exess_read_hex(const char *str, size_t out_size, void *out)

Read a binary value from a hex string.

Canonical syntax is an even number of uppercase hexadecimal digits with no whitespace, like “666F6F”. Lowercase hexadecimal is also supported, and all whitespace is skipped when reading.

The caller must allocate a large enough buffer to read the value, otherwise an ExessStatus.EXESS_NO_SPACE error will be returned. The required space can be calculated with exess_decoded_hex_size().

When this is called, out must point to a buffer of at least out_size bytes. The returned result contains the exact size of the decoded data, which may be smaller than out_size. Only these first bytes are written, the rest of the buffer isn’t modified.

Parameters:
  • str – String to parse.

  • out_size – Size of out in bytes.

  • out – Decoded binary data.

Returns:

The read_count of characters read, write_count of bytes written, and a status.

ExessResult exess_write_hex(size_t data_size, const void *data, size_t buf_size, char *buf)

Write a canonical hexBinary string.

The data is always written in canonical form, as an even number of uppercase hexadecimal digits with no whitespace.

Parameters:
  • data_size – Size of data in bytes.

  • data – Data to write.

  • buf_size – Size of buf in bytes.

  • buf – Output buffer, or null to only measure.

Returns:

The count of characters in the output, and a status (ExessStatus.EXESS_SUCCESS, or ExessStatus.EXESS_NO_SPACE if the buffer is too small).