File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ function _isValidUTF8(buf) {
32
32
let i = 0 ;
33
33
34
34
while ( i < len ) {
35
- if ( buf [ i ] < 0x80 ) {
35
+ if ( ( buf [ i ] & 0x80 ) === 0 ) {
36
36
// 0xxxxxxx
37
37
i ++ ;
38
38
} else if ( ( buf [ i ] & 0xe0 ) === 0xc0 ) {
@@ -43,9 +43,9 @@ function _isValidUTF8(buf) {
43
43
( buf [ i ] & 0xfe ) === 0xc0 // Overlong
44
44
) {
45
45
return false ;
46
- } else {
47
- i += 2 ;
48
46
}
47
+
48
+ i += 2 ;
49
49
} else if ( ( buf [ i ] & 0xf0 ) === 0xe0 ) {
50
50
// 1110xxxx 10xxxxxx 10xxxxxx
51
51
if (
@@ -56,9 +56,9 @@ function _isValidUTF8(buf) {
56
56
( buf [ i ] === 0xed && ( buf [ i + 1 ] & 0xe0 ) === 0xa0 ) // Surrogate (U+D800 - U+DFFF)
57
57
) {
58
58
return false ;
59
- } else {
60
- i += 3 ;
61
59
}
60
+
61
+ i += 3 ;
62
62
} else if ( ( buf [ i ] & 0xf8 ) === 0xf0 ) {
63
63
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
64
64
if (
@@ -71,9 +71,9 @@ function _isValidUTF8(buf) {
71
71
buf [ i ] > 0xf4 // > U+10FFFF
72
72
) {
73
73
return false ;
74
- } else {
75
- i += 4 ;
76
74
}
75
+
76
+ i += 4 ;
77
77
} else {
78
78
return false ;
79
79
}
You can’t perform that action at this time.
0 commit comments