下面的代码是以字节为单位获得字符串的长度。
<html
<head>
</head>
<body>
<script>
  String.prototype.lenB=function()
  {
   return this.replace(/[^\x0-\xf]/g,"##").length;
  }
  var sName="a聪慧b";
  alert(sName.lenB());
</script>
</body>
</html>上面的代码是我直接从书上搞下来的,我总觉得这代码有点问题。
\x0-\xf  这十六进制编码代表什么东西啊。。一直没查到。请教大家 ,谢谢。