| 66906 | nb = utf8CheckByte(buf[j]); |
| 66907 | if (nb >= 0) { |
| 66908 | if (nb > 0) self.lastNeed = nb - 2; |
| 66909 | return nb; |
| 66910 | } |
| 66911 | if (--j < i || nb === -2) return 0; |
| 66912 | nb = utf8CheckByte(buf[j]); |
| 66913 | if (nb >= 0) { |
| 66914 | if (nb > 0) { |
| 66915 | if (nb === 2) nb = 0;else self.lastNeed = nb - 3; |
| 66916 | } |
| 66917 | return nb; |
| 66918 | } |
| 66919 | return 0; |
| 66920 | } |
| 66921 | |
| 66922 | // Validates as many continuation bytes for a multi-byte UTF-8 character as |
| 66923 | // needed or are available. If we see a non-continuation byte where we expect |
| 66924 | // one, we "replace" the validated continuation bytes we've seen so far with |
| 66925 | // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding |
| 66926 | // behavior. The continuation byte check is included three times in the case |
| 66927 | // where all of the continuation bytes for a character exist in the same buffer. |
| 66928 | // It is also done this way as a slight performance increase instead of using a |