File: encode-hex.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (52 lines) | stat: -rw-r--r-- 1,233 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
encode-hex \-  (hex-encoding)
.SH PURPOSE
Encode data into hexadecimal string.

.SH SYNTAX

.RS 4
.EX

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

.EE
.RE

.SH 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.

.SH 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:

.RS 4
.EX

set-string mydata = "\ex00""A""\ex00""\exF""AB""\ex00""\ex04"
encode-hex mydata to hexout input-length 7 prefix "\\\\ex"

.EE
.RE

The value of "hexout" will be:

.RS 4
.EX

\\ex0041000F414200

.EE
.RE

.SH SEE ALSO
 Hex encoding

\fBdecode-hex\fP  
\fBencode-hex\fP   
See all 
\fBdocumentation\fP