Converts the hexadecimal encoded data in hex into raw bytes in the bytes output string. If hex does not consist of valid hexadecimal data, this function returns false and leaves bytes in an unspecified state. Returns true on success.

Synopsis

Declared in <absl/strings/escaping.h>

[[nodiscard]]
bool
HexStringToBytes(
    std::string_view hex,
    std::string* bytes);

Return Value

true on success, false if hex is not valid hexadecimal data.

Note

The return value should not be discarded.

Parameters

Name

Description

hex

The hexadecimal‐encoded string to decode.

bytes

The output string that receives the decoded bytes.

Created with MrDocs