HexStringToBytes overloads

Synopses

Declared in <absl/strings/escaping.h>

Converts an ASCII hex string into bytes, returning binary data of length from.size()/2. The input must be valid hexadecimal data, otherwise the return value is unspecified.

[[deprecated("Use the HexStringToBytes() that returns a bool")]]
std::string
HexStringToBytes(std::string_view from);

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.

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

Return Value

  • The decoded binary data.

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

Parameters

Name

Description

from

The hexadecimal‐encoded string to decode.

hex

The hexadecimal‐encoded string to decode.

bytes

The output string that receives the decoded bytes.

Created with MrDocs