in

SDT Community Server

SDT Forums, Blogs, Photos server.

Coolboy

判断是否为汉字的functons.

C#

  public bool IsCharacter(string strInput)
  {
   try
   {
    char c=char.Parse(strInput);
    if(c>0x7f)
    {
     //就一般是汉字..
     return true;
    }
    else
    {
     return false;
    }
   }
   catch
   {
    return false;
   }
  }

BLOCKED SCRIPT

function StrLen(str) { return str.replace(/[^\x00-\xff]/g,"**").length;//-str.length; }

function test()

{

var a="你死啦";

if(StrLen(a)-a.Length>0)

{

alert("有汉字啊!");

}else

{

 alert("无汉字");

}

}

Comments

 

jawance said:

贬斥用“你XX”的样子做demo
August 16, 2006 5:25 PM
Copyright SDT, 2006-2009. All rights reserved.