[Lazarus-es] comportamiento erratico de TBase64EncodingStream
JoshyFun
joshyfun en gmail.com
Dom Oct 4 18:57:18 CEST 2009
Hello Rafael,
Sunday, October 4, 2009, 6:15:37 PM, you wrote:
>> Cual es el código que te da un encode diferente ?
RB> este:
Te das cuenta que estás usando buffer para todo ? Lo usas como
intermediario y como resultado.
procedure TForm1.Button1Click(Sender: TObject);
var
bufferEncoded: TMemoryStream;
BufferData: TMemoryStream;
EncodeStream : TBase64EncodingStream;
begin
bufferEncoded := TMemoryStream.create();
bufferData := TMemoryStream.Create();
Memo1.Lines.SaveToStream(bufferData);
EncodeStream := TBase64EncodingStream.Create(bufferEncoded);
bufferData.position := 0;
EncodeStream.Write(bufferData.Memory^, bufferData.size);
//EncodeStream.Write hace que se graben los datos
//en base64 en el stream esclavo, en este caso BufferEncoded.
bufferEncoded.position := 0;
Memo2.Lines.LoadFromStream(bufferEncoded);
EncodeStream.free;
bufferEncoded.free;
bufferData.free;
end;
RB> procedure TForm1.Button1Click(Sender: TObject);
RB> var
RB> buffer : TMemoryStream;
RB> EncodeStream : TBase64EncodingStream;
RB> begin
RB> buffer := TMemoryStream.create();
RB> Memo1.Lines.SaveToStream(buffer);
RB> EncodeStream := TBase64EncodingStream.Create(buffer);
RB> buffer.position := 0;
RB> EncodeStream.Write(buffer.Memory^, buffer.size);
RB> buffer.position := 0;
RB> Memo2.Lines.LoadFromStream(buffer);
RB> EncodeStream.free;
RB> buffer.free;
RB> end;
--
Best regards,
JoshyFun
More information about the Lazarus-es
mailing list