Home Contents | # string.fromhex | String | Core4 Lua Commands

## SYNOPSIS

result = string.fromhex(s [, i [, j]])

## DESCRIPTION

Decodes hexadecimal encoded ASCII data into binary.

When i and/or j are given, uses the substring s[i], s[i+1], ···, s[j].
The default value for i is 1; the default value for j is the number of characters in s.

## RETURN VALUE

String containing the decoded data. The result has exactly half the length of data.

## ERRORS

Passed data must be a string, or else an error is thrown.
If data is not of even length or contains characters that are not valid in hexadecimal notation, this function returns nil.

## EXAMPLE

>
print(string.fromhex("41424344342A"))
ABCD4*

## SEE ALSO

string.tohex, string.from64, string.to64, string.hexdump