你是指网页上还是Delphi上显示乱码,网页上的话也要设置相应页面为UTF8,
如果是DELPHI上要显示uft8的话,取出的内容用函数转换下
function unicode2gb( unicodestr:string):string;
var
SourceLength:integer;
DoneLength:integer;
AscNo:integer;
Byte1,Byte2,Byte3:integer;
GbStr:string;
begin
result:='';
if Trim(unicodestr)='' then exit;
SourceLength:=Length(UnicodeStr);
DoneLength:=1;
repeat
AscNo:=ord(UnicodeStr[DoneLength]);
case (AscNo and $E0) of
$E0:begin
Byte1:=(AscNo and $0f) shl 12;
Inc(DoneLength);
if DoneLength>SourceLength then break;
AscNo:=ord(UnicodeStr[DoneLength]);
Byte2:=(AscNo and $3f) shl 6;
Inc(DoneLength);
if DoneLength>SourceLength then break;
AscNo:=ord(UnicodeStr[DoneLength]);
Byte3:=AscNo and $3f;
end;
$C0:begin
Byte1:=(AscNo and $1f) shl 6;
Inc(DoneLength);
if DoneLength>SourceLength then break;
AscNo:=ord(UnicodeStr[DoneLength]);
Byte2:=(AscNo and $3f);
Byte3:=0;
end;
0..$bf:begin
Byte1:=AscNo;
Byte2:=0;
Byte3:=0;
end;
end; //case;
GbStr:=GBStr+widechar(Byte1+Byte2+Byte3);
Inc(DoneLength);
if DoneLength>SourceLength then break;
until DoneLength>SourceLength;
result:=GbStr;
end;
不麻烦呀,函数你复制我上面写的这个就行了。你输出时调用下就行了。比如你Delphi上定义两变量,s1,s2;取的内容先放到一个变量s1上,显示时输出S2,用我的函数调用下就行了,
var
s1,s2 : string;
begin
s2 := unicode2gb(s1);
end;