Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
返回字符串的实际长度
// 返回字符串的实际长度, 一个汉字算2个长度
String.prototype.strlen = function () {
return this.replace(/[^\x00-\xff]/g, "**").length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment