//判断中文
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;
}
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;
}
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>
取其ASC码,最高位为1(第八位)即为一个汉字,一个汉字占两个字节,若要继续判断后面的字符,下一个字符注意应加二.
现在最新的是ASCII<0