Delphi-字节到B64编码字符串的数组[0..693]

Delphi-字节到B64编码字符串的数组[0..693],delphi,bytearray,base64,delphi-xe2,Delphi,Bytearray,Base64,Delphi Xe2,我的代码中有一个声明的变量,如下所示: Var VarName:Array[0..693] of Byte = ( and my array here ); 我已加入我的用途 我希望使用EncdDecd.pas中的EncodeBase64函数将这个字节数组编码为base64字符串 但我不确定如何将其返回到一个漂亮的b64字符串中,该字符串可以直接转换回使用DecodeBase64的字节数组 我试过几种不同的方法 Var Res:PWideChar; begin StringToW

我的代码中有一个声明的变量,如下所示:

Var
   VarName:Array[0..693] of Byte = ( and my array here );
我已加入我的用途

我希望使用EncdDecd.pas中的EncodeBase64函数将这个字节数组编码为base64字符串

但我不确定如何将其返回到一个漂亮的b64字符串中,该字符串可以直接转换回使用DecodeBase64的字节数组

我试过几种不同的方法

Var Res:PWideChar;
begin
    StringToWideChar(EncodeBase64(@VarName, 693), Res, 693);
    ClipBoard.SetTextBuf(Res);
end;
使用该代码访问冲突

还尝试:

begin
    ClipBoard.SetTextBuf(PWideChar(EncodeBase64(@VarName, 693)));
end;
返回一个充满扭曲的中文符号的字符串

如果您能帮助归还此字符串,我们将不胜感激


谢谢

函数声明为

function  DecodeBase64(const Input: AnsiString): TBytes;
function  EncodeBase64(const Input: Pointer; Size: Integer): AnsiString;
所以在Unicode Delphi中,您只需要将AnsiString转换为字符串

var S: string;

begin
  S:= string(EncodeBase64(@VarName, 693));
  ..
要解码S,应将其转换为AnsiString:

var B: TBytes;

begin
  B:= DecodeBase64(AnsiString(S));
  ..

在中声明的函数
DecodeBase64
EncodeBase64
是什么单位?