BASE64ENCODE

BASE64ENCODE encodes a source buffer into a buffer holding its base 64 value in the character set specified by the ASCII or EBCDIC suboption of the DEFAULT compiler option. It returns a size_t value that indicates the number of bytes that are written into the target buffer.

Read syntax diagramSkip visual syntax diagram
>>-BASE64ENCODE(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.
The returned value depends on the address of the target buffer or the size of the target buffer:
Note: Some arguments or return values are of type size_t. If the LP(32) compiler option is in effect, size_t is FIXED BIN(31); if the LP(64) compiler option is in effect, size_t is FIXED BIN(63).

Convention for encoding a source buffer into base 64 as EBCDIC

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

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

Each 6 bits of the source is converted to the corresponding EBCDIC "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 '='e symbols as needed.

Because the source buffer is treated as a bit string, the result in the target buffer varies with the code page of the source.

The following table shows the example of the sources and the corresponding results when converting source buffer into base 64 that is encoded as EBCDIC by using BASE64ENCODE:

Table 1. Example of encoding a source buffer into base 64 as EBCDIC
Source length Source value Result length Result value
6 'please'A 8 cGxlYXNl
5 'pleas'A 8 cGxlYXM=
4 'plea'A 8 cGxlYQ==





Published: 23 December 2018