<script>
/*** 返回字节数 ***/
String.prototype.lenb = function() {
  return this.replace(/[^\x00-\xff]/g,"**").length;
}alert("中国".lenb()); //out 4
</script><?php
function ch_strlen($s) {
  preg_match_all("/[\x80-\xff]?./",$s,$a);
  return count($a[0]);
}echo ch_strlen("中国"); //out 2
?>