Skip to content

Instantly share code, notes, and snippets.

@MaxArt2501 MaxArt2501/codepointat.js
Last active Jul 16, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.