#include <libc.h>
int dec64(uchar *out, int lim, char *in, int n)
int enc64(char *out, int lim, uchar *in, int n)
int dec32(uchar *out, int lim, char *in, int n)
int enc32(char *out, int lim, uchar *in, int n)
int dec16(uchar *out, int lim, char *in, int n)
int enc16(char *out, int lim, uchar *in, int n)
int encodefmt(Fmt*)
Dec16 , dec32 and dec64 return the number of bytes decoded or -1 if the decoding fails. The decoding fails if the output buffer is not large enough or, for base 32, if the input buffer length is not a multiple of 8.
Encodefmt can be used with fmtinstall (2) and print (2) to print encoded representations of byte arrays. The verbs are
3 H base 16 (i.e. hexadecimal). The default encoding is in upper case. The l flag forces lower case.
< base 32
[ base 64 (same as MIME)
The length of the array is specified as f2 . For example, to display a 15 byte array as hex:
.EX char x[15]; fmtinstall('H', encodefmt); print("%.*H\\n", sizeof x, x);