GOLF(2gg)

NAME
encode-hex - (hex-encoding)

PURPOSE
Encode data into hexadecimal string.

SYNTAX

        encode-hex <data> to <output> \
            [ input-length <input length> ] \
            [ prefix <prefix> ]

DESCRIPTION
encode-hex will encode string <data> to hexadecimal string <output> given in "to" clause which consists of digits "0"-"9" and letters "a"-"f".

The length of <data> to encode may be given with <input length> number in "input-length" clause; if not the whole string <data> is used. If you wish to prefix the output with a string <prefix>, you can specify it in "prefix" clause with <prefix>; otherwise no prefix is prepended.

EXAMPLES
Create hexadecimal string from binary data "mydata" of length 7, prefixed with string "\\ex" (which is typically needed for PostgreSQL binary input to queries). The output string "hexout" is created:

        set-string mydata = "\x00""A""\x00""\xF""AB""\x00""\x04"
        encode-hex mydata to hexout input-length 7 prefix "\\ex"

The value of "hexout" will be:

        \ex0041000F414200

SEE ALSO
 Hex encoding

decode-hex encode-hex See all documentation