不过已经解决了~~HttApp里面有个HtmlDeCode函数,不过对于UNICODE支持不了,如果是汉字就无法解析了,后来改写函数,Result原来是String 现在改成WideString ,然后再进行相应字符转换,还是比较麻烦~
相关代码如下
function HTMLDecodeEx(const AStr: String): Widestring;
var
Sp, Cp, Tp: PChar;
Rp
WideString;
S: String;
I, Code: Integer;
begin
SetLength(Result, Length(AStr));
Sp := PChar(AStr);
Rp := PWideString(Result);
Cp := Sp;
try
while Sp^ <> #0 do
begin
case Sp^ of
'&': begin
Cp := Sp;
Inc(Sp);
case Sp^ of
'a': if AnsiStrPos(Sp, 'amp;') = Sp then { do not localize }
begin
Inc(Sp,3);
PInteger(Rp)^ := Integer('&');
end;
'l',
'g': if (AnsiStrPos(Sp, 'lt;') = Sp) or (AnsiStrPos(Sp, 'gt;') = Sp) then { do not localize }
begin
Cp := Sp;
Inc(Sp, 2);
while (Sp^ <> ';') and (Sp^ <> #0) do
Inc(Sp);
if Cp^ = 'l' then
PInteger(Rp)^ := Integer('<')
else
PInteger(Rp)^ := Integer('>');
end;
'q': if AnsiStrPos(Sp, 'quot;') = Sp then { do not localize }
begin
Inc(Sp,4);
PInteger(Rp)^ := Integer('"');
end;
'#': begin
Tp := Sp;
Inc(Tp);
while (Sp^ <> ';') and (Sp^ <> #0) do
Inc(Sp);
SetString(S, Tp, Sp - Tp);
Val(S, I, Code);
PInteger(Rp)^ := I;
end;
else
begin
result:='';
exit;
end;
end;
end
else ;
PInteger(Rp)^ := Integer(Sp^);
end;
Inc(PByte(Rp),2);
Inc(Sp);
end;
SetLength(Result, PChar(Rp)-PChar(Result));
except
result:='';
end;
end;