File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ function _isValidUTF8(buf) {
3232 let i = 0 ;
3333
3434 while ( i < len ) {
35- if ( buf [ i ] < 0x80 ) {
35+ if ( ( buf [ i ] & 0x80 ) === 0 ) {
3636 // 0xxxxxxx
3737 i ++ ;
3838 } else if ( ( buf [ i ] & 0xe0 ) === 0xc0 ) {
@@ -43,9 +43,9 @@ function _isValidUTF8(buf) {
4343 ( buf [ i ] & 0xfe ) === 0xc0 // Overlong
4444 ) {
4545 return false ;
46- } else {
47- i += 2 ;
4846 }
47+
48+ i += 2 ;
4949 } else if ( ( buf [ i ] & 0xf0 ) === 0xe0 ) {
5050 // 1110xxxx 10xxxxxx 10xxxxxx
5151 if (
@@ -56,9 +56,9 @@ function _isValidUTF8(buf) {
5656 ( buf [ i ] === 0xed && ( buf [ i + 1 ] & 0xe0 ) === 0xa0 ) // Surrogate (U+D800 - U+DFFF)
5757 ) {
5858 return false ;
59- } else {
60- i += 3 ;
6159 }
60+
61+ i += 3 ;
6262 } else if ( ( buf [ i ] & 0xf8 ) === 0xf0 ) {
6363 // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
6464 if (
@@ -71,9 +71,9 @@ function _isValidUTF8(buf) {
7171 buf [ i ] > 0xf4 // > U+10FFFF
7272 ) {
7373 return false ;
74- } else {
75- i += 4 ;
7674 }
75+
76+ i += 4 ;
7777 } else {
7878 return false ;
7979 }
You can’t perform that action at this time.
0 commit comments