3 dec64, enc64, dec32, enc32, dec16, enc16, \
4 dec64chr, enc64chr, dec32chr, enc32chr, dec16chr, enc16chr, \
5 encodefmt \- encoding byte arrays as strings
12 int dec64(uchar *out, int lim, char *in, int n)
15 int enc64(char *out, int lim, uchar *in, int n)
18 int dec32(uchar *out, int lim, char *in, int n)
21 int enc32(char *out, int lim, uchar *in, int n)
24 int dec16(uchar *out, int lim, char *in, int n)
27 int enc16(char *out, int lim, uchar *in, int n)
50 The functions described here handle encoding and decoding of
51 bytes to printable ASCII strings as specified by RFC4648.
57 create null terminated strings. They return the size of the
58 encoded string (without the null) or -1 if the encoding fails.
61 the length of the output buffer (including null), is too small.
67 return the number of bytes decoded or -1 if the decoding fails.
68 The decoding fails if the output buffer is not large enough or,
69 for base 32, if the input buffer length is not a multiple
76 return the value for a symbol of the alphabet or -1 when the
77 symbol is not in the alphabet.
83 encode a symbol of the alphabet given a value.
84 if the value is out of range then zero is returned.
91 to print encoded representations of byte arrays.
95 base 16 (i.e. hexadecimal). The default encoding is
98 flag forces lower case.
101 base 32. The default is upper case, same as
105 base 64 (same as MIME)
108 The length of the array is specified as
110 For example, to display a 15 byte array as hex:
115 fmtinstall('H', encodefmt);
116 print("%.*H\\n", sizeof x, x);
120 .B /sys/src/libc/port/u16.c
122 .B /sys/src/libc/port/u32.c
124 .B /sys/src/libc/port/u64.c
126 .B /sys/src/libc/port/encodefmt.c
128 In Jan 2018, base 32 encoding was changed from non-standard
129 to standard RFC4648 alphabet.
132 .B "23456789abcdefghijkmnpqrstuvwxyz"
135 .B "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"