Ich hatte gerade vor einger Zeit ein ähnliches Problem und habe es so gelöst:
Delphi-Quellcode:
unit Config.Encoder;
interface
uses
IdCoderMIME;
type
TEncoder =
class
private
class var
FEncoder : TIdEncoderMIME;
FDecoder : TIdDecoderMIME;
public
class constructor Create;
class destructor Destroy;
class function Encode(
const AValue :
string) :
string;
class function Decode(
const AValue :
string) :
string;
end;
implementation
{ TEncoder }
class constructor TEncoder.Create;
begin
FEncoder := TIdEncoderMIME.Create;
FDecoder := TIdDecoderMIME.Create;
end;
class function TEncoder.Decode(
const AValue:
string):
string;
begin
Result := FDecoder.DecodeString(AValue);
end;
class destructor TEncoder.Destroy;
begin
FEncoder.Free;
FDecoder.Free;
end;
class function TEncoder.Encode(
const AValue:
string):
string;
begin
Result := FEncoder.EncodeString(AValue)
end;
end.