0

In FMX, I could use the System.NetEncoding unit for encoding and decoding Base64 Strings in Delphi, but this unit doesn't seem to be available in TMS Web Core:

[Error] uMain_web.pas(29): can't find unit "System.NetEncoding"

What is the TMS Web Core alternative for System.NetEncoding or for decoding/encoding Base64?

2 Answers 2

0

Unfortunately, System.NetEncoding isn't available for TMS Web Core.

In TMS Web Core, you can use window.btoa() and window.atob() though. btoa encodes and atob decodes.

var
  EncodedString: String;
  DecodedString: String;
begin
  EncodedString := window.btoa('Shaun Roselt'); // Encode String to Base64
  DecodedString := window.atob('U2hhdW4gUm9zZWx0'); // Decode Base64 String
end;
Sign up to request clarification or add additional context in comments.

Comments

-1

We can use System.NetEncoding in TMS Web Core v2.3.0.0:

uses 
  System.NetEncoding;

procedure TForm1.WebButton1Click(Sender: TObject);
var
  Encoded, Decoded: String;
  Coder: TBase64Encoding;
begin
  Coder := TBase64Encoding.Create;
  Encoded := Base64Encoding.Encode('Shaun Roselt');
  Decoded := Base64Encoding.Decode(Encoded);
  Coder.Free;
end;

1 Comment

This isn't true. I tested it on v2.3.0.0 and on v2.3.1.0. I still get the can't find unit "System.NetEncoding" error. Can you add your source of where you saw that System.NetEncoding was added in v2.3.0.0?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.