Hello Péter,
Thanks for your help.
I have updated the source code as follow. Please check if this works for you
before I commit the change to the repository.
function THttpConnection.HtmlPageProducerToString(
const HtmlFile : String;
UserData : TObject;
Tags : array of const) : String;
var
Stream : TMemoryStream;
const
NulByte : Byte = 0;
begin
Stream := TMemoryStream.Create;
try
HtmlPageProducerToStream(HtmlFile, UserData, Tags, Stream);
{$IFDEf COMPILER12_UP}
// For unicode char compiler (D2009 and up)
// Add a nul byte at the end of string
Stream.Write(NulByte, 1);
Result := String(PAnsiChar(Stream.Memory));
{$ELSE}
// For ansi char compiler
SetLength(Result, Stream.Size);
Stream.Seek(0, 0);
Stream.Read(Result[1], Stream.Size);
{$ENDIF}
finally
Stream.Free;
end;
end;
--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be
----- Original Message -----
From: "Busai Péter" <busai...@t-online.hu>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Monday, January 24, 2011 9:24 PM
Subject: Re: [twsocket] HtmlPageProducerToString in Delphi XE
One possible solution, I defined a temporary RawByteString and now it
returns correct result.
I have tested it on DelphiXE and BDS2006.
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *}
function THttpConnection.HtmlPageProducerToString(
const HtmlFile : String;
UserData : TObject;
Tags : array of const) : String;
var
Stream : TMemoryStream;
{$IFDEF COMPILER12_UP}
S : RawByteString;
{$ELSE}
S : String;
{$END}
begin
Stream := TMemoryStream.Create;
try
HtmlPageProducerToStream(HtmlFile, UserData, Tags, Stream);
SetLength(S, Stream.Size);
Stream.Seek(0, 0);
Stream.Read(S[1], Stream.Size);
Result := S;
finally
Stream.Free;
end;
end;
Regards
Peter
--------------------------------------------------------------------------------
A(z) kimenő üzenetben nem található vírus.
Ellenőrizte: AVG - www.avg.com
Verzió: 9.0.872 / Vírus adatbázis: 271.1.1/3400 - Kiadás dátuma: 01/24/11
08:35:00
--------------------------------------------------------------------------------
--
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
--
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