base64Decode

base64Decode(): Binary;

The base64Decode method of the String primitive type returns a Binary value resulting from the decoding of a Base64-encoded message. A Base64-encoded message contains characters from the following alphabet.

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

The message may also contain line-break characters (Cr and Lf) inserted by the Base64 encoding algorithm; these are ignored by the decoder, as are any characters that are not in the Base64 alphabet.

Use the base64Encode or base64EncodeNoCrLf method on the String primitive type to encode a binary value using Base64 encoding.

The following example shows the use of the base64Decode method.

vars
    bin: Binary;
    file: File;
begin
    create file;
    file.fileName := "d:\temp\harry.jpg";
    file.kind := File.Kind_Binary;
    file.open;
    bin := file.readBinary(file.fileLength);
    write 'original length = ' & bin.length.String;
    write 'base64Encode length = ' & bin.base64Encode().length.String;
    write 'base64EncodeNoCrLf length = ' &
                                     bin.base64EncodeNoCrLf().length.String;
    write 'base64Decode length = ' &
                            bin.base64Encode().base64Decode().length.String;
    write 'base64Decode length (from NoCrLf) = ' &
                        bin.base64EncodeNoCrLf().base64Decode.length.String;
     file.close;
epilog
    delete file;
end;

The length of an encoded string is about a third longer, even if the string is encoded with carriage-return and line-feed (Cr and Lf) characters.