(ptr)
| 897 | |
| 898 | var UTF16Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-16le') : undefined; |
| 899 | function UTF16ToString(ptr) { |
| 900 | var endPtr = ptr; |
| 901 | // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself. |
| 902 | // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage. |
| 903 | var idx = endPtr >> 1; |
| 904 | while (HEAP16[idx]) ++idx; |
| 905 | endPtr = idx << 1; |
| 906 | |
| 907 | if (endPtr - ptr > 32 && UTF16Decoder) { |
| 908 | return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)); |
| 909 | } else { |
| 910 | var i = 0; |
| 911 | |
| 912 | var str = ''; |
| 913 | while (1) { |
| 914 | var codeUnit = HEAP16[(((ptr)+(i*2))>>1)]; |
| 915 | if (codeUnit == 0) return str; |
| 916 | ++i; |
| 917 | // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through. |
| 918 | str += String.fromCharCode(codeUnit); |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | |
| 924 | // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…