delphi 判断字符串有中文

delphi 判断字符串有中文,第1张

概述function TForm1.IsHaveChinese(judgeStr: string; var posInt: integer): boolean;var p: PWideChar; // 要判断的字符 count: integer; // 包含汉字位置 isHave: boolean; // 是否包含汉字返回值begin isHave := false; // 是否
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..#FA5:        begin          isHave := true; // 设置是否包含汉字返回值为true          posInt := count; // 设置包含汉字位置          break; // 退出循环        end;    end;    Inc(p);    Inc(count); // 包含汉字位置递增  end;  result := isHave;end;
总结

以上是内存溢出为你收集整理的delphi 判断字符串中文全部内容,希望文章能够帮你解决delphi 判断字符串有中文所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1274881.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-08
下一篇2022-06-08

发表评论

登录后才能评论

评论列表(0条)

    保存