BASE64 (FUN)¶
FUNCTION BASE64 : PT_SIZE
encodes 8 bit binary data into ASCII data
A text block (string, binary, array of bytes) will be base64 encoded. The maximum of the block is set in the TextBlockSize parameter. This size can be changed but must be divisible by 3.
If the text block is only a part of a text and followed by more text, the size must be TextBlockSize.iBlockSize
and
the isLastBlock
variable must be set to FALSE
. If a text is not followed by another block, the specific length
of it must be used and isLastBlock
has to be set to TRUE
, as shown in the following example. The reason is
three 8-bit letters will become four 6-bit letters. If only two 8-Bit letters are remaining at the end, the encoded text is
filled with „=“. This must only be at the end of a text.
Example:
StringToConvert : PT_SIZE;
EncodedString : PT_SIZE;
byError : BYTE;
sText : STRING := 'This is a test string.';
StringToConvert.uiSize := LEN(sText); (* When another block follows, use the size TextBlockSize.iBlockSize
and set isLastBlock to FALSE. *)
StringToConvert.pString := ADR(sText);
EncodedString := Base64(TextToEncode := StringToConvert, isLastBlock := TRUE, pbyError := ADR(byError));
- InOut:
Scope
Name
Type
Comment
Return
BASE64
A structure with a pointer to the text and its size (comprising the terminating character)
Input
TextToEncode
The text block which should be encoded
isLastBlock
BOOL
TRUE
: The current text block is the end of a textFALSE
: The current text block is just a small textpbyError
POINTER TO BYTE
0: No error1: Text block is too long2: Not divisible through 34: Empty string