Skip to content

Instantly share code, notes, and snippets.

@MaySnow
Last active December 29, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaySnow/7601232 to your computer and use it in GitHub Desktop.
Save MaySnow/7601232 to your computer and use it in GitHub Desktop.
带中文字符串的字节数
String.prototype.chinaLength = function() {
var result = this.match(/[\u0080-\uFFE5]/g);
if (result) {
return this.length + result.length;
}
return this.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment