Skip to content

Instantly share code, notes, and snippets.

@jarontai
Created September 1, 2014 09:18
Show Gist options
  • Select an option

  • Save jarontai/76594a9edf5c51d3cba5 to your computer and use it in GitHub Desktop.

Select an option

Save jarontai/76594a9edf5c51d3cba5 to your computer and use it in GitHub Desktop.
calculate the length of string which includes Chinese character
var len = content.match(/[^ -~]/g) == null ? content.length : content.length + content.match(/[^ -~]/g).length;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment