trichview.com

trichview.support




Re: SaveRVFToStream


Return to index


Author

Message

Sergey Tkachenko

Posted: 10/04/2004 18:38:19


The statement

BufferStr := Buffer;

copies the string from Buffer to BufferStr up to the first #0 character.

But:

- #0 characters can be inside RVF (for example, if it contains images); if

it happens, BufferStr will not contain complete RVF data;

- #0 character is not written to the end of RVF data. So extra "garbage"

characters can be copied in BufferStr until #0 is reached.


You can read RVF directly in BufferStr:


SetLength(BufferStr, Stream.Size);

Stream.ReadBuffer( PChar(BufferStr)^ , Stream.Size );



> Hi,

> Just a quick question about SaveRVFToStream.

> When i use this function it works ok but i seem to be getting a few

"stray"

> characters at the end of the buffer like it has overrun the buffer or

something.

> Not sure if i am doing something stupid in my code or if there is a bug

with

> the SaveRVFToStream function. An example is shown below.

>

> procedure TForm1.Button1Click(Sender: TObject);

> var

>  Stream : TMemoryStream;

>  Buffer : PChar;

>  BufferStr : String;

> begin

>  RichViewEdit.RVFOptions := RichViewEdit.RVFOptions - [rvfoSaveBinary];

>  Stream := TMemoryStream.Create;

>  RichViewEdit.SaveRVFToStream( Stream , false );

>  Stream.Position := 0;

>  GetMem( Buffer , Stream.Size );

>  Stream.ReadBuffer( Buffer^ , Stream.Size );

>  BufferStr := Buffer;

>  FreeMem( Buffer );

>  Stream.free;

>  showmessage( BufferStr );

> end;

>

> If you notice in the showmessage dialog a couple of characters which

appear

> to be out of range. Any help would be appreciated.

>

> Thanks.





Powered by ABC Amber Outlook Express Converter