{ "deadbeef" } [ B{ 222 173 190 239 } bytes>hex-string ] unit-test
{ B{ 222 173 190 239 } } [ "deADbeEF" hex-string>bytes ] unit-test
+[ "0" hex-string>bytes ] [ invalid-hex-string-length? ] must-fail-with
{
B{ 49 46 53 53 69 43 48 53 }
: # ( n -- ) number>string % ; inline
+ERROR: invalid-hex-string-length n ;
+
: hex-string>bytes ( hex-string -- bytes )
- dup length 2/ <byte-array> [
+ dup length dup even? [ invalid-hex-string-length ] unless 2/ <byte-array> [
[
[ digit> ] 2dip over even? [
[ 16 * ] [ 2/ ] [ set-nth-unsafe ] tri*