Created
January 5, 2019 07:47
-
-
Save 607011/1d39ddf8b5b7fe42094ed35ffe1b7913 to your computer and use it in GitHub Desktop.
Calculate length of unicode string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(String.prototype, 'unicodeLength', { | |
get: function() { | |
return this.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '.').length; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment