>Delphi HTTPApp unit, function HTMLDecode
Wow! I had no idea of this unit, Thanks a lot! HTTP date parsing, Cookies (!), 
entuity en/decoding... THttpCli might take some useful code from this unit :)
But as I see, HTMLEncode touches only special chars. If that's what you need, 
fine. You may also use my function which I wrote for a XML:

const
  XmlCtrlChars = '<>&"''';
  XmlEntities: array[1..Length(XmlCtrlChars)] of TXmlString = ('lt', 'gt', 
'amp', 'quot', 'apos');

// Replaces special chars by entity-codes
function TextToXML(const aText: TXmlString): TXmlString;
var CtrlCharIdx, PrevIdx, CurrIdx: Integer;
begin
  PrevIdx := 1; Result := '';
  CurrIdx := 1;
  while CurrIdx <= Length(aText) do
  begin
    CtrlCharIdx := Pos(aText[CurrIdx], XmlCtrlChars);
    if CtrlCharIdx <> 0 then
    begin
      Result := Result + Copy(aText, PrevIdx, CurrIdx - PrevIdx) + 
'&'+XmlEntities[CtrlCharIdx]+';';
      PrevIdx := CurrIdx + 1;
    end;
    Inc(CurrIdx);
  end;
  if Result = ''
    then Result := aText
    else Result := Result + Copy(aText, PrevIdx, CurrIdx - PrevIdx);
end;

If you need full replacement of all entities, I may share that code too but 
it's much bigger (because of all entities declaration)

-- 
Anton
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to