Last active
July 16, 2016 21:09
-
-
Save MaxArt2501/2879438bfc3dcad64bfb85a71070fe1e to your computer and use it in GitHub Desktop.
A polyfill for `String.prototype.codePointAt`
This file contains 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
String.prototype.codePointAt || (String.prototype.codePointAt = function(index) { | |
var code = this.charCodeAt(index); | |
if (code >= 0xd800 && code <= 0xdbff) { | |
var surr = this.charCodeAt(index + 1); | |
if (surr >= 0xdc00 && surr <= 0xdfff) | |
code = 0x10000 + ((code - 0xd800) << 10) + (surr - 0xdc00); | |
} | |
return code; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment