I'm looking to encode a string variable to UTF-16LE and base64 , the problem is that I find nothing about how to do UTF-16LE in Delphi.
Example in Python :
from base64 import b64encode
b64encode('my text'.encode('UTF-16LE'))
Example in Ruby :
require "base64"
Base64.encode64('my text'.force_encoding('UTF-16LE'))
As I can do this in Delphi?
Updated :
procedure TFormTest.btnTestClick(Sender: TObject);
var
dest, src: TEncoding;
srcBytes, destBytes: TBytes;
Encoder: TIdEncoderMime;
begin
Encoder := TIdEncoderMime.Create(nil);
src := TEncoding.Unicode;
srcBytes := src.GetBytes(Edit1.Text);
Edit2.Text := Encoder.EncodeBytes(srcBytes);
FreeAndNil(Encoder);
end;
Is a valid base64 UTF-16LE created?
Powershell tells me it is invalid
Command to use :
(New-Object System.Net.WebClient).DownloadFile('http://localhos/update_program.exe','updater.exe'); Start-Process 'updater.exe'
Output error :
Missing expression after unary operator '-'.
TEncoding.Unicode.GetBytes(str)to encode as UTF-16LE. Then use one of the many base64 encoders. Try some websearch.