//判断中文
function getLength(charset)
{
    var i,cnt = 0;
    for(i=0; i<charset.length; i++)
      if (escape(zwzf.charAt(i)).length >= 4 ) cnt+=2;
     else cnt++;    return cnt;
}

解决方案 »

  1.   

    <script>
    var a="中国是Liang feijun的祖国";
    for(i=0;i<a.length;i++){
      if(a.charCodeAt(i)>=0xA0)
        document.write(a.substr(i,1) + ":是中文<br>");
      else
        document.write(a.substr(i,1) + ":是英文<br>");}
    </script>
      

  2.   

    只需要用str.codeatchar判断是不是大于128就行了
      

  3.   


    取其ASC码,最高位为1(第八位)即为一个汉字,一个汉字占两个字节,若要继续判断后面的字符,下一个字符注意应加二.
      

  4.   

    过时了。现在是UNICODE
    现在最新的是ASCII<0