还是用我这个函数吧:
function Unicode2String(var sChg: String): Integer;
var //查找并替换串中的Unicode编码为字符串(返回个数)
i, k, iVal: Integer; //注意,这里并未为字符串前后加上单引号'
sWide: String;
begin
Result := 0;
i := 1;
while i <= Length(sChg) do
begin
if sChg = '#' then //找到可能的开始符
begin
k := i + 1;
iVal := 0;
while (k <= Length(sChg)) and (sChg[k] in ['0'..'9']) do
begin //本循环搜索数字串并求值
iVal := iVal * 10 + (Ord(sChg[k]) - Ord('0'));
Inc(k);
end;
if iVal > 127 then //找到一个WideChar
begin
Delete(sChg, i, k - i);
sWide := WideString(WideChar(iVal));
Insert(sWide, sChg, i);
Inc(i, Length(sWide));
Inc(Result); //找到并替换的个数
end
else //遇到诸如'#'之类的串
i := k;
end
else
Inc(i);
end;
end;
调用:
var
sTemp: string;
begin
sTemp := '#30830#23450';
if Unicode2String(sTemp) > 0 then begin
ShowMessage(sTemp);
end;