Recent

Author Topic: [SOLVED] Decode html symbols  (Read 325 times)

artem101

  • Full Member
  • ***
  • Posts: 120
[SOLVED] Decode html symbols
« on: May 01, 2026, 04:52:56 pm »
Is there any built-in solution in Lazarus for decode html entries like ", ' and etc.?

Something like this:
Code: Pascal  [Select][+][-]
  1. s := '"hello" 'world'';
  2. s := decode_html(s);
  3. writeln(s); // "hello" 'world'

Or I need to "reinvent the bicycle"?
« Last Edit: May 01, 2026, 08:51:26 pm by artem101 »

dsiders

  • Hero Member
  • *****
  • Posts: 1615
Re: Decode html symbols
« Reply #1 on: May 01, 2026, 05:31:33 pm »
Is there any built-in solution in Lazarus for decode html entries like ", ' and etc.?

Something like this:
Code: Pascal  [Select][+][-]
  1. s := '"hello" 'world'';
  2. s := decode_html(s);
  3. writeln(s); // "hello" 'world'

Or I need to "reinvent the bicycle"?

FCL includes EscapeHtml and UnescapeHtml routines in fcl-xml/src/htmlelements.pp. They handle the common name entities you mentioned.

wp

  • Hero Member
  • *****
  • Posts: 13515
Re: Decode html symbols
« Reply #2 on: May 01, 2026, 05:37:00 pm »
Or uses ResolveHTMLEntityReference in unit HtmlDefs:
Code: Pascal  [Select][+][-]
  1. uses
  2.  HtmlDefs;
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. var
  5.   entity: String;
  6.   wCh: WideChar;
  7. begin
  8.   entity := 'Auml';
  9.   if ResolveHTMLEntityReference(WideString(entity), wCh) then
  10.     ShowMessage(entity + ' --> ' + UTF8Encode(wCh));
  11. end;

artem101

  • Full Member
  • ***
  • Posts: 120
Re: Decode html symbols
« Reply #3 on: May 01, 2026, 08:51:12 pm »
FCL includes EscapeHtml and UnescapeHtml routines in fcl-xml/src/htmlelements.pp. They handle the common name entities you mentioned.

This is what I need. Thanks.

 

TinyPortal © 2005-2018