Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Decode Base64 into Memo or file
#7
Hi, 

sorry but I have some problems with the suggestions indicated above ...

if the file to be decoded is "simple" ... to the work ....
if instead there are special characters it does NOT work ...

as an attachment it is possible to view the generated file (correct.xml.p7m) and instead the one generated by my delphi code (NotCorrected.xml.p7m)

the code
...............................................

Code:
var
  sfile : AnsiString;
  Base64 : AnsiString;
  IDBytes : TIdBytes;
begin
  ...  
  lHTTP := TIdHTTP.Create;

  //sfile  string in precedent post  (coded64)

  IDBytes := TIdDecoderMIME.DecodeBytes(sfile);
  Base64 := BytesToString(IDBytes, IndyTextEncoding_UTF8);

  StrToFile('c:\temp\NotCorrect.xml.p7m', Base64);
  ...

strtofile is e simple procedure:

Code:
procedure StrToFile(const FileName, SourceString: AnsiString);
var
  Stream : TFileStream;
begin
  Stream:= TFileStream.Create(FileName, fmCreate);
  try
    Stream.WriteBuffer(Pointer(SourceString)^, Length(SourceString));
  finally
    Stream.Free;
  end;
end;

thanks
Alessandro Romano
Reply


Messages In This Thread
RE: Decode Base64 into Memo or file - by rlebeau - 05-14-2019, 08:13 AM
RE: Decode Base64 into Memo or file - by staff@ergosoft.it - 06-25-2019, 03:06 PM
RE: Decode Base64 into Memo or file - by rlebeau - 06-25-2019, 05:52 PM
RE: Decode Base64 into Memo or file - by kudzu - 06-25-2019, 04:47 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)