介绍
本文章介绍了Delphi XE6 实现Base64字符串的解析,首先将Base64字符串转换成TStringStream,然后将TStringStream字符串转换成UTF8.
具体代码
procedure TForm1.Button1Click(Sender: TObject,',',');
var f: TFileStream;
InStr, OutStr: TStringStream;
begin
f := TFileStream.Create('D:\大富翁论坛\文章发布\Android Test Base64\json.txt', fmOpenRead,',',');
InStr := TStringStream.Create;
InStr.CopyFrom(f, f.Size,',',');
Memo1.Text := InStr.DataString;
InStr.Position := 0;
OutStr := TStringStream.Create;
DecodeStream(InStr, OutStr,',',');
Memo2.Text := TEncoding.UTF8.GetString(OutStr.Bytes,',',');
f.Free;
InStr.Free;
OutStr.Free;
end;
关键字词: