From: Jesse Tane Date: Tue, 11 Aug 2015 04:44:05 +0000 (-0400) Subject: replace unicode in the surrogate pair range the way node@3 does X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=3e1bdd0dae6d387c7ec3ab6d800ede055814d20f;p=buffer.git replace unicode in the surrogate pair range the way node@3 does --- diff --git a/index.js b/index.js index 623e7cf..b5f4588 100644 --- a/index.js +++ b/index.js @@ -669,7 +669,7 @@ function utf8Slice (buf, start, end) { thirdByte = buf[i + 2] if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF) { + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { codePoint = tempCodePoint } }