Jak poprawnie zdekodować tekst w formacie BASE64 do UTF-8?

0

Używam Delphi 7 + TNT ( https://github.com/rofl0r/TntUnicode ) + indy 10
Chodzi o to aby po zdekodowaniu xIXEh8W8xbrFhMOzxYLEmQ== uzyskać ąćżźńółę

na razie dostaje coś takiego

title

procedure TForm1.Button1Click(Sender: TObject);
var text:widestring;
    enc: TIdTextEncoding;
begin
 text:=form1.IdDecoderMIME1.DecodeString('xIXEh8W8xbrFhMOzxYLEmQ==',enc.UTF8,enc.UTF8);
 form1.TntMemo1.Text:=text;
end;
1

Ok już mam.

title

function UTF8ToWideString(const S: AnsiString): WideString;
var BufSize: Integer;
begin
  Result := '';
  if Length(S) = 0 then Exit;
  BufSize := MultiByteToWideChar(CP_UTF8, 0, PAnsiChar(S), Length(S), nil, 0);
  SetLength(result, BufSize);
  MultiByteToWideChar(CP_UTF8, 0, PANsiChar(S), Length(S), PWideChar(Result), BufSize);
end;

procedure TForm1.Button1Click(Sender: TObject);
var text:string;
    enc: TIdTextEncoding;
begin
 text:=form1.IdDecoderMIME1.DecodeString('xIXEh8W8xbrFhMOzxYLEmQ==',enc.UTF8,enc.UTF8);
 form1.TntMemo1.Text:=UTF8ToWideString(text);
end;

1 użytkowników online, w tym zalogowanych: 0, gości: 1