delphi 判断 中文字符  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 判断 中文字符


delphi 判断 中文字符
sql正则表达:
select * from gamelog.game2_0log_100_20121012 where not objectname regexp "[\x4e00-\x9fff]"
缺点: 只能查询到完全中文(字符中不包括任何非中文)

mysql:
SELECT * FROM gamelog.game2_0log_100_20121012  where char_length(objectname)!=length(objectname)
缺点:只对 字符中 包括 中文 和外文的有用 (双字节判断)

 
delphi: 
function TForm2.IsCN(sText: string): Boolean;
var
  I: Integer;
begin
  Result := False;
  if sText = '' then Exit;
  for I := 0 to Length(sText) do
  begin
    if (Ord(sText[I]) >= $4E00{19968})  and  (Ord(sText[I]) <=  $9FA5{40869}) then
    begin
      Result := True;
      break;
    end;
  end;
end;
推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.03821587562561 seconds