Lazarus Pascal Requires Chilkat v11.2.0+
Lazarus Pascal
Base62 Encoding and Decoding
Demonstrates base62 encoding and decoding.Chilkat Lazarus Pascal Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.BinData,
Chilkat.StringBuilder;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
bd: TBinData;
base62_encoded: string;
sb: TStringBuilder;
begin
bd := TBinData.Create;
// Base62 encode.
bd.AppendString('hello world','utf-8');
base62_encoded := bd.GetEncoded('base62');
WriteLn('hello world --> ' + base62_encoded);
// Output:
// hello world --> AAwf93rvy4aWQVw
// Base62 decode
sb := TStringBuilder.Create;
sb.DecodeAndAppend('AAwf93rvy4aWQVw','base62','utf-8');
WriteLn('decoded: ' + sb.GetAsString());
// Output:
// decoded: hello world
bd.Free;
sb.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.