summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/56_hexdec
blob: cb842ca613bf195adc53d2b8e35927d3e014f8ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
The `hexdec()` function decodes the given hexadecimal digit string into
a byte string, optionally skipping specified characters.

Returns null if the input string contains invalid characters or an uneven
amount of hex digits.

Returns the decoded byte string on success.

-- Testcase --
{%
	printf("%.J\n", [
		hexdec("44 55 66 77 33 44\n"),   	// whitespace is skipped by default
		hexdec("44-55-66:77-33-44", ":-"),	// skip specified characters
		hexdec("abc"),						// error; uneven amount of digits
		hexdec("ab cd !"),					// error; non-whitespace, non-hex, non-skipped char
		hexdec(1234),						// error; non-string input
	]);
%}
-- End --

-- Expect stdout --
[
	"DUfw3D",
	"DUfw3D",
	null,
	null,
	null
]
-- End --