比如一个中文字占2个字符,"准确长度asdf"用length属性好像是8,但是放进数据库就是12了.
<script language="JavaScript">
<!--
//取字符串字节长度
String.prototype.getByteLength = function ()
{
return this.replace(/[^\x00-\xff]/g,"00").length;
}
alert("准确长度asdf".getByteLength());
//-->
</script>