W wugdoneone Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-20 #1 因为要分别对汉字与英文字母进行处理! 谢谢先!
完 完颜康 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-20 #2 ord(char)>127 为汉字的一部分(一个汉字战两个字节)
Z zw84611 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-20 #3 wyh919 (2002-1-22 14:43:00) 用ByteType() Function Judge(S:String):Boolean; var i: integer; begin result:= False; for i:= 0 to Length(S)-1do begin if (ByteType(S,i) <> mbSingleByte) then begin result:= True;//含有中文字符或其它双字节字符 break; end; end; end;
wyh919 (2002-1-22 14:43:00) 用ByteType() Function Judge(S:String):Boolean; var i: integer; begin result:= False; for i:= 0 to Length(S)-1do begin if (ByteType(S,i) <> mbSingleByte) then begin result:= True;//含有中文字符或其它双字节字符 break; end; end; end;
J jsxjd Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-20 #4 procedure TForm1.Button1Click(Sender: TObject); var s,ss:string; ws:widestring; i:integer; begin s:='AA在地一345677工在五00-$%#'; ws:=s; ss:=''; for i:=1 to length(ws)do if length(string(ws))>1 then ss:=ss+'汉' else ss:=ss+'A'; showmessage(s+#13+ss); end;
procedure TForm1.Button1Click(Sender: TObject); var s,ss:string; ws:widestring; i:integer; begin s:='AA在地一345677工在五00-$%#'; ws:=s; ss:=''; for i:=1 to length(ws)do if length(string(ws))>1 then ss:=ss+'汉' else ss:=ss+'A'; showmessage(s+#13+ss); end;
T tseug Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-20 #5 var B : Byte; S : String; I : Integer; begin I := 1; while I <= Length(S)do begin B := ord(S); if isDBCSLeadByte(B) then begin //汉字 Inc(I, 2); end else begin //字母 Inc(I); end end; end;
var B : Byte; S : String; I : Integer; begin I := 1; while I <= Length(S)do begin B := ord(S); if isDBCSLeadByte(B) then begin //汉字 Inc(I, 2); end else begin //字母 Inc(I); end end; end;