Base 64 is used to encode binary data for applications that only accept text. It is commonly used in Internet Mail applications to send and receive binary data.
This library contains one string source function
and one string sink function
, as follows:
reader
is a string source function
that reads its value string source
argument, and returns the binary data of that data converted from a Base 64 encoding to raw binary octets.
That is, the provided data is in Base 64, but the program sees binary data.
writer
is a string sink function
that accepts raw binary data and writes that data
to its value string sink
argument, converted from binary data to a Base 64 encoding. That is, the
program writes binary data, but the provided output receives Base 64.
Any input data not recognized as part of a Base 64 encoding is ignored, so this library should not be used to validate Base 64 encoding.
writer
has an optional first argument, heralded by width
, that is the line width of
the Base 64 output. The default is 76, in keeping with the specification for Base 64 encoding. The Base 64
output has line breaks, represented by a carriage-return/line-feed (CR+LF) sequence after the number of characters
(of the Base 64 encoding) specified in the optional first argument. The Base 64 output always has a CR+LF at its
end.
The optional first argument of writer
can alternatively have a value of zero (0), in which case no
CR+LF sequences are produced, and the output consists entirely of encoded data.
The Base 64 encoding used is based on that described in [1] IETF RFC 2045, “Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies”.
To use OMFFBASE64, you must import it into your program using an import declaration such as:
import "omffbase64.xmd" prefixed by base64.