File tree 2 files changed +16
-12
lines changed
2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,15 @@ function utf8_decode ( str_data ) {
20
20
if ( c1 < 128 ) {
21
21
tmp_arr [ ac ++ ] = String . fromCharCode ( c1 ) ;
22
22
i ++ ;
23
- } else if ( ( c1 > 191 ) && ( c1 < 224 ) ) {
24
- c2 = str_data . charCodeAt ( i + 1 ) ;
23
+ }
24
+ else if ( c1 > 191 && c1 < 224 ) {
25
+ c2 = str_data . charCodeAt ( i + 1 ) ;
25
26
tmp_arr [ ac ++ ] = String . fromCharCode ( ( ( c1 & 31 ) << 6 ) | ( c2 & 63 ) ) ;
26
27
i += 2 ;
27
- } else {
28
- c2 = str_data . charCodeAt ( i + 1 ) ;
29
- c3 = str_data . charCodeAt ( i + 2 ) ;
28
+ }
29
+ else {
30
+ c2 = str_data . charCodeAt ( i + 1 ) ;
31
+ c3 = str_data . charCodeAt ( i + 2 ) ;
30
32
tmp_arr [ ac ++ ] = String . fromCharCode ( ( ( c1 & 15 ) << 12 ) | ( ( c2 & 63 ) << 6 ) | ( c3 & 63 ) ) ;
31
33
i += 3 ;
32
34
}
Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ function utf8_encode ( argString ) {
13
13
14
14
var string = ( argString + '' ) ; // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
15
15
16
- var utftext = "" ;
17
- var start , end ;
18
- var stringl = 0 ;
16
+ var utftext = "" ,
17
+ start , end ,
18
+ stringl = 0 ;
19
19
20
20
start = end = 0 ;
21
21
stringl = string . length ;
@@ -25,22 +25,24 @@ function utf8_encode ( argString ) {
25
25
26
26
if ( c1 < 128 ) {
27
27
end ++ ;
28
- } else if ( c1 > 127 && c1 < 2048 ) {
28
+ }
29
+ else if ( c1 > 127 && c1 < 2048 ) {
29
30
enc = String . fromCharCode ( ( c1 >> 6 ) | 192 ) + String . fromCharCode ( ( c1 & 63 ) | 128 ) ;
30
- } else {
31
+ }
32
+ else {
31
33
enc = String . fromCharCode ( ( c1 >> 12 ) | 224 ) + String . fromCharCode ( ( ( c1 >> 6 ) & 63 ) | 128 ) + String . fromCharCode ( ( c1 & 63 ) | 128 ) ;
32
34
}
33
35
if ( enc !== null ) {
34
36
if ( end > start ) {
35
- utftext += string . substring ( start , end ) ;
37
+ utftext += string . slice ( start , end ) ;
36
38
}
37
39
utftext += enc ;
38
40
start = end = n + 1 ;
39
41
}
40
42
}
41
43
42
44
if ( end > start ) {
43
- utftext += string . substring ( start , string . length ) ;
45
+ utftext += string . slice ( start , stringl ) ;
44
46
}
45
47
46
48
return utftext ;
You can’t perform that action at this time.
0 commit comments