]> zoso.dev Git - buffer.git/commitdiff
replace unicode in the surrogate pair range the way node@3 does
authorJesse Tane <jesse.tane@gmail.com>
Tue, 11 Aug 2015 04:44:05 +0000 (00:44 -0400)
committerJesse Tane <jesse.tane@gmail.com>
Tue, 11 Aug 2015 05:39:45 +0000 (01:39 -0400)
index.js

index 623e7cfcb305a974e7edad5d29aa3008aadcd6bd..b5f4588d3e811fe2a5d5c95c5e68b41c54419d4f 100644 (file)
--- 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
             }
           }