bytes>hex-string ( bytes -- hex-string ) - Factor Documentation

bytes>hex-string ( bytes -- hex-string )
Hex Strings



Vocabulary
hex-strings

Inputs
bytes a sequence


Outputs
hex-string a string


Word description
Converts a sequence of bytes (integers in the range [0,255]) to a string of hex numbers in the range [00,ff].

Examples
USING: hex-strings prettyprint ; B{ 1 2 3 4 } bytes>hex-string .
"01020304"


Notes
Numbers are zero-padded on the left.

See also
hex-string>bytes

Definition
USING: kernel math math.parser sequences sequences.private
strings ;

IN: hex-strings

: bytes>hex-string ( bytes -- hex-string )
dup length 2 * 48 <string> [
[
[ 16 /mod [ >digit ] bi@ ] [ 2 * dup 1 + ]
[ [ set-nth-unsafe ] curry bi-curry@ bi* ] tri*
] curry each-index
] keep ;

AltStyle によって変換されたページ (->オリジナル) /