var i = start
while (i < end) {
var firstByte = buf[i]
- var codePoint = 0xFFFD
+ var codePoint = null
var bytesPerSequence = (firstByte > 0xEF) ? 4
: (firstByte > 0xDF) ? 3
: (firstByte > 0xBF) ? 2
}
}
- if (codePoint === 0xFFFD) {
- // we generated an invalid codePoint so make sure to only advance by 1 byte
+ if (codePoint === null) {
+ // we did not generate a valid codePoint so insert a
+ // replacement char (U+FFFD) and advance only 1 byte
+ codePoint = 0xFFFD
bytesPerSequence = 1
} else if (codePoint > 0xFFFF) {
// encode to utf16 (surrogate pair dance)