base64EncodeNoCrLf

base64EncodeNoCrLf(): String;

The base64EncodeNoCrLf method of the Binary primitive type returns an ASCII string resulting from the encoding of the receiver using the Base64 encoding technique defined in RFC 1521.

Base64 encoding enables 8-bit data to be converted, so that it can be transmitted over a protocol that supports 7-bit characters only. Base64 encoding also provides enhanced privacy when the source data is standard ASCII text, as the message is no longer in clear text when it is transmitted.

Unlike the base64Encode method, the output is not broken up into lines; that is, it does not contain carriage-return and line-feed (Cr and Lf) characters.

Use the base64Decode method on the String primitive type to decode a Base64-encoded string.

The following example shows the use of the base64EncodeCrLf 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.