BASE64ENCODE8 encodes the source buffer into base 64 that is encoded as UTF-8. It returns a size_t 1 value that indicates the number of bytes that are written into the target buffer.
>>-BASE64ENCODE8(p,m,q,n)--------------------------------------><
If the address of the target buffer is zero, the number of bytes that would be written is returned. If the target buffer is not large enough, a value of -1 is returned. If the target buffer is large enough, the number of bytes that is written to the buffer is returned.
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
Each 6 bits of the source is converted to the corresponding UTF-8 "digit" in this base 64 string. If the source length in bits is not a multiple of 6, the result concludes with one or two = symbols as needed, and the = symbol is UTF-8.
The source buffer is treated as a bit string, so the result in the target buffer varies with the code page of the source. In particular, when the source is in EBCDIC, the result differs when the source is in ASCII.
The following table shows the example of the sources and the corresponding results when converting source buffer into base 64 that is encoded as UTF-8 by using BASE64ENCODE8:
Source length | Source value | Result length | Result value |
---|---|---|---|
6 | 'please'A | 8 | UTF8('cGxlYXNl') |
5 | 'pleas'A | 8 | UTF8('cGxlYXM=') |
4 | 'plea'A | 8 | UTF8('cGxlYQ==') |
6 | 'please'E | 8 | UTF8('l5OFgaKF') |
5 | 'pleas'E | 8 | UTF8('l5OFgaI=') |
4 | 'plea'E | 8 | UTF8('l5OFgQ==) |