function DecodeHTMLText(S:string):WideString;
type
THTMLCharType=(GenChar,DeciUnicodeChar,HexUnicodeChar);
var
ps
Char;
pd
WideChar;
si,di:integer;
CharType:THTMLCharType;
CodeCharSets:array [DeciUnicodeChar..HexUnicodeChar] of set of char;
CharCode
WORD;
begin
CodeCharSets[DeciUnicodeChar]:=['0'..'9'];
CodeCharSets[HexUnicodeChar]:=['0'..'9','a'..'f','A'..'F'];
ps:=Pointer(S);
si:=1;
SetLength(Result,Length(S));
pd:=Pointer(Result);
di:=0;
CharType:=GenChar;
CharCode:=0;
While ps[si-1]<>#0 do
begin
if CharType=GenChar then
begin
if (ps[si-1]='&') and (si<Length(S)) and (ps[si]='#') then
begin
if si+1<Length(S) then
begin
if ps[si+1] in ['x','X'] then
begin
CharType:=HexUnicodeChar;
si:=si+2
end
else
begin
CharType:=DeciUnicodeChar;
si:=si+1
end
end
else
begin
pd[di]:=WideChar(ps[si-1]);
inc(di)
end
end
else
begin
pd[di]:=WideChar(ps[si-1]);
inc(di)
end
end
else
if ps[si-1] in CodeCharSets[CharType] then
case CharType of
DeciUnicodeChar:
CharCode:=CharCode*10+StrToInt(ps[si-1]);
HexUnicodeChar:
CharCode:=CharCode*16+StrToInt('$'+ps[si-1])
end
else
begin
pd[di]:=WideChar(CharCode);
inc(di);
CharType:=GenChar;
CharCode:=0
end;
inc(si)
end;
SetLength(Result,di)
end;
把你的编码字符串输入这个函数,返回的就是你要的汉字了。