一个网页里面存在\u65b0\u6d6a\u4f53\u80b2\的字符串,如何转成字符啊?

解决方案 »

  1.   

    function UnicodeToAnsi(aSubUnicode: string):string;
    var tmpLen,iCount:Integer;
        tmpWS:WideString;
    begin
      tmpWS:='';
      iCount:=1;
      tmpLen:=Length(aSubUnicode);
      while iCount<=tmpLen do
        try
          if (Copy(aSubUnicode, iCount, 1)='\')and (Copy(aSubUnicode, iCount, 2)='\u') then begin
            tmpWS:=tmpWS+WideChar(StrToInt('$'+Copy(aSubUnicode,iCount+2,4)));
            iCount:=iCount+6;
          end
          else begin
            tmpWS:=tmpWS+Copy(aSubUnicode,iCount,1);
            iCount:=iCount+1;
          end;
        except
        end;
      Result:=tmpWS;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      showmessage(UnicodeToAnsi('\u65b0\u6d6a\u4f53\u80b2'));//显示“新浪体育”
    end;
      

  2.   

    http://topic.csdn.net/u/20120107/18/10829ab3-032b-4456-a06b-3ca2bd5317cf.html?26978
      

  3.   

    这是unicode编码; 自己截取字符串,然后转换成这样的格式就行了ShowMessage(WideChar($65b0));