BASE64ENCODE16 encodes the source buffer into base 64 that is encoded as UTF-16. It returns a size_t 1 value that indicates the number of bytes that are written into the target buffer.
>>-BASE64ENCODE16(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-16 "digit" in the 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-16.
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 examples of the sources and the corresponding results when converting the source buffer into base 64 that is encoded as UTF-16 by using BASE64ENCODE16.
Source length | Source value | Result length | Result value |
---|---|---|---|
6 | 'please'A | 16 | WCHAR('cGxlYXNl') |
5 | 'pleas'A | 16 | WCHAR('cGxlYXM=') |
4 | 'plea'A | 16 | WCHAR('cGxlYQ==') |
6 | 'please'E | 16 | WCHAR('l5OFgaKF') |
5 | 'pleas'E | 16 | WCHAR('l5OFgaI=') |
4 | 'plea'E | 16 | WCHAR('l5OFgQ==') |