Base64 to Binary (Delphi)

前端 未结 5 816
灰色年华
灰色年华 2021-01-03 05:47

I used Binary to Base64 function that you answered : Binary to Base64 (Delphi)

I successfully encode a file to base64 string and write it to MsSQL2008 database, but

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 06:42

    After looking into Soap.EncdDecd the one can find more platform independent way, as it's DecodeBase64 uses universal (no AnsiString) methods from System.NetEncoding.

    Based on Uwe's sample:

    uses
      ...
      System.Classes,
      System.NetEncoding;
    
    ...
    procedure DecodeFile(const base64: String; const FileName: string);
    var
      stream: TBytesStream;
    begin
      stream := TBytesStream.Create(TNetEncoding.Base64.DecodeStringToBytes(base64));
      try
        stream.SaveToFile(Filename);
      finally
        stream.Free;
      end;
    end;
    

提交回复
热议问题