Skip to content

Instantly share code, notes, and snippets.

@MaxArt2501
Last active July 16, 2016 21:09
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 MaxArt2501/2879438bfc3dcad64bfb85a71070fe1e to your computer and use it in GitHub Desktop.
Save MaxArt2501/2879438bfc3dcad64bfb85a71070fe1e to your computer and use it in GitHub Desktop.
A polyfill for `String.prototype.codePointAt`
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