WebBase64Decode Function

Action

Converts ASCII-encoded data into unsigned binary data.

注: This function is obsolete. It can still be used, although it's recommended to use the WebBase64DecodeEx function instead.

Include file

WebAPI.bdh

Syntax

WebBase64Decode( out   sTarget : string,
                 inout nTarget : number,
                 in    sSource : string ): boolean;

Return value

  • true if the decoding was successful

  • false otherwise

Parameter Description
sTarget String variable to receive the data.
nTarget Maximum number of bytes to write into sTarget. This value must be less than or equal to the size of sTarget. nTarget will contain the length of the encoded binary data after a successful return.
sSource Source string to decode.

For example, the string "dGVzdHVzZXI6dGVzdHBhc3M=" is converted to "testuser:testpass".

Example

dcltrans
  transaction TWebBase64Decode
  var
    sPlain    : string;
    sCoded    : string(100);
    nPlainLen : number;
    nCodedLen : number;
  begin
    sPlain := "testuser:testpass";
    write("plain: "); write(sPlain); writeln;

    WebBase64Encode(sCoded, sizeof(sCoded), nCodedLen, sPlain, Strlen(sPlain));
    write("encoded: "); write(sCoded); writeln;

    nPlainLen := sizeof(sPlain);
    WebBase64Decode(sPlain, nPlainLen, sCoded);
    write("decoded: "); write(sPlain); writeln;
  end TWebBase64Decode;

Output

plain: testuser:testpass
encoded: dGVzdHVzZXI6dGVzdHBhc3M=
decoded: testuser:testpass