怎么使二进制(BLOB)转换为Base64编码?(100分)

  • 主题发起人 主题发起人 crpp_hqx
  • 开始时间 开始时间
C

crpp_hqx

Unregistered / Unconfirmed
GUEST, unregistred user!
在用TClientDataSet的SavtToFile方法保存为*.xml文件时,其二进制的数据变成了Base64
编码了,些方法怎么使二进制(BLOB)转换为Base64编码?
 
用TNUUUProcessor控件可以做到编解码!
unit uuedem;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
NMUUE, StdCtrls, ComCtrls, Buttons;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
NMUUE1: TNMUUProcessor;
Edit2: TEdit;
Label2: TLabel;
Button1: TButton;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
GroupBox2: TGroupBox;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
StatusBar1: TStatusBar;
SpeedButton1: TSpeedButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure NMUUE1begin
Decode(Sender: TObject);
procedure NMUUE1begin
Encode(Sender: TObject);
procedure NMUUE1EndDecode(Sender: TObject);
procedure NMUUE1EndEncode(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
InStream,
OutStream: TFileStream;
begin
InStream := TFileStream.Create(Edit1.Text, fmOpenRead);
OutStream := TFileStream.Create(Edit2.Text, fmCreate);
try
If RadioButton4.Checked then
NMUUE1.Method := uuMIME
else
NMUUE1.Method := uuCode;
NMUUE1.InputStream := InStream;
NMUUE1.OutputStream := OutStream;
If RadioButton1.Checked then
NMUUE1.Encode
else
NMUUE1.Decode;
finally
InStream.Free;
OutStream.Free;
end;
end;

procedure TForm1.NMUUE1begin
Decode(Sender: TObject);
begin
StatusBar1.SimpleText := 'Decoding stream';
end;

procedure TForm1.NMUUE1begin
Encode(Sender: TObject);
begin
StatusBar1.SimpleText := 'encoding stream';
end;

procedure TForm1.NMUUE1EndDecode(Sender: TObject);
begin
StatusBar1.SimpleText := 'Completed decoding stream';
end;

procedure TForm1.NMUUE1EndEncode(Sender: TObject);
begin
StatusBar1.SimpleText := 'Completed encoding stream';
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
If OpenDialog1.Execute then
Edit1.Text := OpenDialog1.FileName;
end;

end.
 
不用控件,用一个函数实现怎么做??
 
用encddecd单元中的EncodeStream和DecodeStream函数
 
多人接受答案了。
 

Similar threads

回复
0
查看
848
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部