这是行为(你)的意图吗?
... uses System.NetEncoding; ... var s: String; begin s := TNetEncoding.Base64.Encode('asjjdhgfaoösjkdhföaksjdfhöasjdfhasdkjasdhfköajsjhdfajssssd'); end;
s包含CR LF:
YXNqamRoZ2Zhb8O2c2prZGhmw7Zha3NqZGZow7Zhc2pkZmhhc2RramFzZGhma8O2YWpzamhkZmFq’#$D#$A’c3Nzc2Q =
解决方法
在这种情况下,您可以自己创建具有适当参数的实例:
var s: String; base64: TBase64Encoding; begin base64 := TBase64Encoding.Create(0); // CharsPerLine = 0 means no line breaks try s := base64.Encode('asjjdhgfaoösjkdhföaksjdfhöasjdfhasdkjasdhfköajsjhdfajssssd'); finally base64.Free; end; end;