You are not logged in.
Pages: 1
Hi AB!
My code not working (a couple months ago there was no problem)
function Base64ToBin(const s: RawByteString): RawByteString;
begin
Base64ToBinSafe(pointer(s), length(s), result);
end;
The result variable is ok inside above code, but when I use this function, the return value is empty string.
token := Base64ToBin(aToken);
Delphi 11, latest ORM
Thanks, Csaba
Last edited by HollosCs (2022-02-28 21:53:51)
Offline
Because aToken is not a valid Base-64 encoded content, I guess.
There may be some space, line feed or unexpect character within.
BTW: mORMot 1 or 2?
What is the input? Does it decode on https://www.base64decode.org/ for instance?
(please do not post it directly in this forum but on a gist/pastebin link)
Offline
Hi
I using mormot 2 and before couple of months is no problem.
Base64ToBin conversion is success, but no return value.
Csaba
Offline
Seems to in string from RawByteString (string := RawByteString) conversation lost data on function result after quit function.
If I use RawByteString on full call chain, result is back.
What is the best/safe conversation RawByteString to String?
Offline
It depends on the string code page, once decoded as bin.
Is it UTF-8? Then use Utf8ToString() or Utf8ToStringVar().
On Delphi, you should make all such conversions explicit.
I guess there was a compiler warning in your source code.
Use an explicit conversion function like Utf8ToString() or Utf8ToStringVar().
In your case, your code is pretty wrong.
Don't define token:string; but token:RawByteString;
You are a little bit confused about the Delphi string types - they are somewhat difficult for sure - so consider looking at the documentation about them.
Offline
Thanks!
You are right, explicit conversation is required. (Perhaps change something in D11). And sorry for take yours time.
Strings are not simple.
Csaba
Offline
Pages: 1