@@ -39,48 +39,45 @@ function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
39
39
#if TEXTDECODER
40
40
if ( endPtr - idx > 16 && heapOrArray . buffer && UTF8Decoder ) {
41
41
return UTF8Decoder . decode ( { { { getUnsharedTextDecoderView ( 'heapOrArray' , 'idx' , 'endPtr' ) } } } ) ;
42
- } else {
42
+ }
43
43
#endif // TEXTDECODER
44
- var str = '' ;
44
+ var str = '' ;
45
45
#if TEXTDECODER
46
- // If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
47
- while ( idx < endPtr ) {
46
+ // If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
47
+ while ( idx < endPtr ) {
48
48
#else
49
- while ( ! ( idx >= endIdx ) ) {
49
+ while ( ! ( idx >= endIdx ) ) {
50
50
#endif
51
- // For UTF8 byte structure, see:
52
- // http://en.wikipedia.org/wiki/UTF-8#Description
53
- // https://www.ietf.org/rfc/rfc2279.txt
54
- // https://tools.ietf.org/html/rfc3629
55
- var u0 = heapOrArray [ idx ++ ] ;
51
+ // For UTF8 byte structure, see:
52
+ // http://en.wikipedia.org/wiki/UTF-8#Description
53
+ // https://www.ietf.org/rfc/rfc2279.txt
54
+ // https://tools.ietf.org/html/rfc3629
55
+ var u0 = heapOrArray [ idx ++ ] ;
56
56
#if ! TEXTDECODER
57
- // If not building with TextDecoder enabled, we don't know the string length, so scan for \0 byte.
58
- // If building with TextDecoder, we know exactly at what byte index the string ends, so checking for nulls here would be redundant.
59
- if ( ! u0 ) return str ;
57
+ // If not building with TextDecoder enabled, we don't know the string length, so scan for \0 byte.
58
+ // If building with TextDecoder, we know exactly at what byte index the string ends, so checking for nulls here would be redundant.
59
+ if ( ! u0 ) return str ;
60
60
#endif
61
- if ( ! ( u0 & 0x80 ) ) { str += String . fromCharCode ( u0 ) ; continue ; }
62
- var u1 = heapOrArray [ idx ++ ] & 63 ;
63
- if ( ( u0 & 0xE0 ) == 0xC0 ) { str += String . fromCharCode ( ( ( u0 & 31 ) << 6 ) | u1 ) ; continue ; }
64
- var u2 = heapOrArray [ idx ++ ] & 63 ;
65
- if ( ( u0 & 0xF0 ) == 0xE0 ) {
66
- u0 = ( ( u0 & 15 ) << 12 ) | ( u1 << 6 ) | u2 ;
67
- } else {
61
+ if ( ! ( u0 & 0x80 ) ) { str += String . fromCharCode ( u0 ) ; continue ; }
62
+ var u1 = heapOrArray [ idx ++ ] & 63 ;
63
+ if ( ( u0 & 0xE0 ) == 0xC0 ) { str += String . fromCharCode ( ( ( u0 & 31 ) << 6 ) | u1 ) ; continue ; }
64
+ var u2 = heapOrArray [ idx ++ ] & 63 ;
65
+ if ( ( u0 & 0xF0 ) == 0xE0 ) {
66
+ u0 = ( ( u0 & 15 ) << 12 ) | ( u1 << 6 ) | u2 ;
67
+ } else {
68
68
#if ASSERTIONS
69
- if ( ( u0 & 0xF8 ) != 0xF0 ) warnOnce ( 'Invalid UTF-8 leading byte 0x' + u0 . toString ( 16 ) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!' ) ;
69
+ if ( ( u0 & 0xF8 ) != 0xF0 ) warnOnce ( 'Invalid UTF-8 leading byte 0x' + u0 . toString ( 16 ) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!' ) ;
70
70
#endif
71
- u0 = ( ( u0 & 7 ) << 18 ) | ( u1 << 12 ) | ( u2 << 6 ) | ( heapOrArray [ idx ++ ] & 63 ) ;
72
- }
71
+ u0 = ( ( u0 & 7 ) << 18 ) | ( u1 << 12 ) | ( u2 << 6 ) | ( heapOrArray [ idx ++ ] & 63 ) ;
72
+ }
73
73
74
- if ( u0 < 0x10000 ) {
75
- str += String . fromCharCode ( u0 ) ;
76
- } else {
77
- var ch = u0 - 0x10000 ;
78
- str += String . fromCharCode ( 0xD800 | ( ch >> 10 ) , 0xDC00 | ( ch & 0x3FF ) ) ;
79
- }
74
+ if ( u0 < 0x10000 ) {
75
+ str += String . fromCharCode ( u0 ) ;
76
+ } else {
77
+ var ch = u0 - 0x10000 ;
78
+ str += String . fromCharCode ( 0xD800 | ( ch >> 10 ) , 0xDC00 | ( ch & 0x3FF ) ) ;
80
79
}
81
- #if TEXTDECODER
82
80
}
83
- #endif // TEXTDECODER
84
81
return str ;
85
82
#endif // TEXTDECODER == 2
86
83
}
0 commit comments