delphi 判断字符串有中文
发布时间:2020-12-15 09:56:09 所属栏目:大数据 来源:网络整理
导读:function TForm1.IsHaveChinese(judgeStr: string ; var posInt: integer): boolean; var p: PWideChar; // 要判断的字符 count: integer; // 包含汉字位置 isHave: boolean; // 是否包含汉字返回值 begin isHave : = false; // 是否包含汉字返回值默认为fal
function TForm1.IsHaveChinese(judgeStr: string; var posInt: integer): boolean; var p: PWideChar; // 要判断的字符 count: integer; // 包含汉字位置 isHave: boolean; // 是否包含汉字返回值 begin isHave := false; // 是否包含汉字返回值默认为false count := 1; // 包含汉字位置默认为1 p := PWideChar(judgeStr); // 把要判断字符串转换 // 循环判断每个字符 while p^ <> #0 do begin case p^ of #$4E00..#$9FA5: begin isHave := true; // 设置是否包含汉字返回值为true posInt := count; // 设置包含汉字位置 break; // 退出循环 end; end; Inc(p); Inc(count); // 包含汉字位置递增 end; result := isHave; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |