llvm::tryGetFromHex

Convert a hexadecimal string to binary bytes.

Synopsis

Declared in <llvm/ADT/StringExtras.h>

bool
tryGetFromHex(
    StringRef Input,
    std::string& Output);

Description

Convert hexadecimal string Input to its binary representation and store the result in Output. Returns true if the binary representation could be converted from the hexadecimal string. Returns false if Input contains non-hexadecimal digits. The output string is half the size of Input.

Return Value

True if Input was successfully decoded.

Parameters

NameDescription
Inputhexadecimal text to decode
Outputset to the decoded binary bytes on success