xcall B64ENC, infile, och, status {,flag}
or
xcall B64ENC, indata, outdata, status, flag
B64ENC.SBR provides Base 64 (aka MIME) encoding and decoding. The first format encodes a file, writing the encoded output to another file, while the second format may be used for encoding and decoding of memory buffers.
Parameters
ifile (String) [in]
Specification of file to encode in AMOS or native format
Channel of a file, previously opened for output, to which the encoded version of the input file will be written. The file remains open on return.
status (Signed Num) [out]
On return, will be set to the number of bytes written, or <0 for errors
Value |
Description |
>=0 |
Number of bytes written |
-1 |
infile not found |
-2 |
unable to open infile |
-3 |
och not valid (not open for OUTPUT) |
-4 |
file error during input of file |
-5 |
error during output |
-6 |
outdata too small to hold encrypted output |
indata (X or String) [in]
Variable containing data to encode or decode
outdata (X or String) [out]
Variable containing encoded or decoded version of indata. Since encoded data is 4/3 larger than raw data, the determination of whether the operation is encode or decode is based on the relative sizes of the indata and outdata parameters. If the physical variable outdata is larger than indata, then the operation will be to encode. Otherwise it will be to decode.
flag (Num) [in]
If not specified, or set to 0, the format is assumed to be that given in the first syntax line above (encode a file). Otherwise, to encode a memory buffer, flag must be set to the number of bytes in indata to encode. (Since raw data may contain binary values, including 0, we can not use the normal string length method of determining the logical size of the input data.) To decode data, flag should be set to 1.
Comments
Base 64 encoded data uses only 64 distinct bytes (all printable) for representation, which is often convenient for including binary data within formats that are otherwise string-oriented (such as email). Because only six bits are used in each byte of the encoded representation, the encoded version of the data is 4/3 larger than the raw data. The raw data does not have to be a multiple of three.