你可以用
str.charCodeAt(i)进行判断
类似于
http://www.csdn.net/Develop/read_article.asp?id=13104

解决方案 »

  1.   

    <script language=javascript>
    function check(str){
    var ret=str.length
    try{ret+=str.match(/[^\x00-\xff]/g).length}catch(e){}
    alert(ret)
    }
    check("中A")
    </script>
      

  2.   

    好像都不是很好用,所以我自己用判断asicc的方法来搞定了
      

  3.   

    很老的问题了,呵呵,一个常用的办法(虽然笨一点):function getByteLen(s)
    {
    var n = s.length;
    for ( var i=0; i<s.length; i++ )
    if ( s.charCodeAt(i)<0 || s.charCodeAt(i)>255 )
    n++;
    return n
    }