(u8Array, idx)
| 750 | // a copy of that string as a Javascript String object. |
| 751 | |
| 752 | function UTF8ArrayToString(u8Array, idx) { |
| 753 | var u0, u1, u2, u3, u4, u5; |
| 754 | |
| 755 | var str = ''; |
| 756 | while (1) { |
| 757 | // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629 |
| 758 | u0 = u8Array[idx++]; |
| 759 | if (!u0) return str; |
| 760 | if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; } |
| 761 | u1 = u8Array[idx++] & 63; |
| 762 | if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; } |
| 763 | u2 = u8Array[idx++] & 63; |
| 764 | if ((u0 & 0xF0) == 0xE0) { |
| 765 | u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; |
| 766 | } else { |
| 767 | u3 = u8Array[idx++] & 63; |
| 768 | if ((u0 & 0xF8) == 0xF0) { |
| 769 | u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | u3; |
| 770 | } else { |
| 771 | u4 = u8Array[idx++] & 63; |
| 772 | if ((u0 & 0xFC) == 0xF8) { |
| 773 | u0 = ((u0 & 3) << 24) | (u1 << 18) | (u2 << 12) | (u3 << 6) | u4; |
| 774 | } else { |
| 775 | u5 = u8Array[idx++] & 63; |
| 776 | u0 = ((u0 & 1) << 30) | (u1 << 24) | (u2 << 18) | (u3 << 12) | (u4 << 6) | u5; |
| 777 | } |
| 778 | } |
| 779 | } |
| 780 | if (u0 < 0x10000) { |
| 781 | str += String.fromCharCode(u0); |
| 782 | } else { |
| 783 | var ch = u0 - 0x10000; |
| 784 | str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | Module["UTF8ArrayToString"] = UTF8ArrayToString; |
| 789 | |
| 790 | // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns |
no outgoing calls
no test coverage detected