BASE64ENCODE16

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.

Read syntax diagramSkip visual syntax diagramBASE64ENCODE16( p, m, q, n)
p
Specifies the address of the target buffer.
m
Specifies the length in bytes of the target buffer. It must have a computational type and is converted to type size_t.
q
Specifies the address of the source buffer.
n
Specifies the length in bytes of the source buffer. It must have a computational type and is converted to type size_t.

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.

Convention for encoding a source buffer into base 64 as UTF-16

This encoding uses the following set of base 64 "digits":

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.

Table 1. Example of encoding a source buffer into base 64 as UTF-16
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==')