3 dec64, enc64, dec32, enc32, dec16, enc16, \
4 dec64x, enc64x, dec32x, enc32x, \
5 dec64chr, enc64chr, dec32chr, enc32chr, dec16chr, enc16chr, \
6 encodefmt \- encoding byte arrays as strings
13 int dec64(uchar *out, int lim, char *in, int n)
16 int dec64x(uchar *out, int lim, char *in, int n, int (*map)(int))
19 int enc64(char *out, int lim, uchar *in, int n)
22 int enc64x(char *out, int lim, uchar *in, int n, int (*map)(int))
25 int dec32(uchar *out, int lim, char *in, int n)
28 int dec32x(uchar *out, int lim, char *in, int n, int (*map)(int))
31 int enc32(char *out, int lim, uchar *in, int n)
34 int enc32x(char *out, int lim, uchar *in, int n, int (*map)(int))
37 int dec16(uchar *out, int lim, char *in, int n)
40 int enc16(char *out, int lim, uchar *in, int n)
63 The functions described here handle encoding and decoding of
64 bytes to printable ASCII strings as specified by RFC4648.
70 create null terminated strings. They return the size of the
71 encoded string (without the null) or -1 if the encoding fails.
74 the length of the output buffer (including null), is too small.
80 return the number of bytes decoded or -1 if the decoding fails.
81 The decoding fails if the output buffer is not large enough or,
82 for base 32, if the input buffer length is not a multiple
89 return the value for a symbol of the alphabet or -1 when the
90 symbol is not in the alphabet.
96 encode a symbol of the alphabet given a value.
97 if the value is out of range then zero is returned.
103 variants are identical to the above, except that they take a
104 function mapping from an arbitrary index in the alphabet to
105 the encoded character.
106 For example, in the following 32-character alphabet,
108 .I ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
110 the chr function would map the value
119 variants are similar to the above, however the function passed
120 maps from a character within the alphabet to the index within
129 to print encoded representations of byte arrays.
133 base 16 (i.e. hexadecimal). The default encoding is
136 flag forces lower case.
139 base 32. The default is upper case, same as
143 base 64 (same as MIME)
146 The length of the array is specified as
148 For example, to display a 15 byte array as hex:
153 fmtinstall('H', encodefmt);
154 print("%.*H\\n", sizeof x, x);
158 .B /sys/src/libc/port/u16.c
160 .B /sys/src/libc/port/u32.c
162 .B /sys/src/libc/port/u64.c
164 .B /sys/src/libc/port/encodefmt.c
166 In Jan 2018, base 32 encoding was changed from non-standard
167 to standard RFC4648 alphabet.
170 .B "23456789abcdefghijkmnpqrstuvwxyz"
173 .B "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"