Lazarus Pascal Requires Chilkat v11.1.0+
Lazarus Pascal
HTML Entity Encode and Decode in StringBuilder
Demonstrates HTML encoding and decoding the contents of a StringBuilder.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.StringBuilder;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
sb: TStringBuilder;
s: string;
begin
sb := TStringBuilder.Create;
s := '< é ü ç Ω Hello & World ✓ >';
sb.Append(s);
sb.Encode('html','utf-8');
WriteLn(sb.GetAsString());
// Output:
// < é ü ç Ω Hello & World ✓ >
// To decode:
sb.Decode('html','utf-8');
WriteLn(sb.GetAsString());
// Output:
// < é ü ç Ω Hello & World ✓ >
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.