function sak_QuotedPrintableDecode( const FCurrentData : PChar ): string;
{ This works if charset="iso-8859-1" ! }
var
SourceIndex : Integer;
DecodedIndex : Integer;
Ch : Char;
CodeHex : String;
begin
try
SourceIndex := 0;
DecodedIndex := 0;
if ( FCurrentData <> '' ) and ( FCurrentData^ <> #0 ) then
begin
while TRUE do
begin
Ch := FCurrentData[ SourceIndex ];
if Ch = #0 then
break;
if Ch = '_' then
begin
FCurrentData[ DecodedIndex ] := ' ';
Inc( SourceIndex );
Inc( DecodedIndex );
end else
begin
if Ch <> '=' then
begin
FCurrentData[ DecodedIndex ] := Ch;
Inc( SourceIndex );
Inc( DecodedIndex );
end else
begin
Inc( SourceIndex );
Ch := FCurrentData[ SourceIndex ];
if (Ch = #13) or (Ch = #10) then
begin
Inc( SourceIndex );
Inc( SourceIndex );
end else
begin
CodeHex := '$' + Ch;
Inc( SourceIndex );
Ch := FCurrentData[ SourceIndex ];
if Ch = #0 then break;
CodeHex := CodeHex + Ch ;
FCurrentData[ DecodedIndex ] := Chr( StrToIntDef( CodeHex, 64));
Inc( SourceIndex );
Inc( DecodedIndex );
end;
end;
end;
end;
FCurrentData[ DecodedIndex ] := #0;
end;
Result := FCurrentData;
except
end;
end;
===========================
function BIG52GBK(szBuf:string;code1,code2:Integer):string;
var
nStrLen,nReturn:Integer;
pws:widestring;
bValue:Boolean;
str:string;
begin
str:=szBuf;
if str = '' then
str := ''
else
begin
nStrLen := Length(str);
SetLength(pws, nStrLen + 1);
ZeroMemory(PWideChar(pws),nStrLen + 1);
// SetLength(pws, nStrLen + 1);
try
nReturn:=MultiByteToWideChar(code1, 0, PChar(str), nStrLen, PWideChar(pws), nStrLen + 1);
bValue:=False;
nReturn := WideCharToMultiByte(code2, 0, PWideChar(pws), nReturn, PChar(str), nStrLen + 1,'?',nil);
Result:= str;
except
end;
end;
end;