Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 7-使用TidDecoderMie解码Base64_Delphi_Base64_Delphi 7_Memorystream - Fatal编程技术网

Delphi 7-使用TidDecoderMie解码Base64

Delphi 7-使用TidDecoderMie解码Base64,delphi,base64,delphi-7,memorystream,Delphi,Base64,Delphi 7,Memorystream,好吧,这让我快发疯了,哈哈 我有一个Base64字符串,正在尝试使用TidDecoderMie将其解码为TMemoryStream 我目前的代码如下: Var MStream:TMemoryStream; Decoder:TIdDecoderMIME; begin Decoder := TIdDecoderMIME.Create(nil); MStream := TMemoryStream.Create; Decoder.DecodeToStream(BSting,MStream);

好吧,这让我快发疯了,哈哈

我有一个Base64字符串,正在尝试使用TidDecoderMie将其解码为TMemoryStream

我目前的代码如下:

Var MStream:TMemoryStream; Decoder:TIdDecoderMIME;
begin
  Decoder := TIdDecoderMIME.Create(nil);
  MStream := TMemoryStream.Create;
  Decoder.DecodeToStream(BSting,MStream);
end;
其中BString=我的Base64字符串

现在,当代码运行时,我收到一条错误消息,“DecodeToString中的大小不均匀。”

有什么想法吗


非常感谢您的帮助。谢谢。

您正在向
DecodeToStream
函数传递长度不是4倍数的Base64字符串。换句话说,您传递的字符串无效。

Base64字符串通常用尾随的“=”符号填充,以确保其长度为4的倍数

一些解码器将尝试更正缺少的填充字符,而其他解码器则不会。请参阅StackOverflow问题“”

TidDecoderMie对象通过确保输入是4的倍数来验证输入——如果输入中包含填充字符,则为4的倍数