问:如何去一字符串中的中文字符???
如:xxx我是中国人xxxxxxx
如何去出中文字符???

解决方案 »

  1.   

    将字符串转换成Unicode然后判断每个字符的宽度,为1表示字母,为2表示是汉字
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
        str: string;
        i: integer;
        temp : string;
    begin
        str := 'i love you 中国';
        temp := '';
        i := 0;
        while i < length(str) do
        begin
            while IsDBCSLeadByte(byte(str[i])) do
            begin
                temp := temp + widestring(str[i]+str[i+1]);
                i := i+2;
            end;
            inc(i);
        end;
        showmessage(temp);
    end;end.