MCPcopy Create free account
hub / github.com/sql-js/sql.js / UTF32ToString

Function UTF32ToString

js/sql-debug.js:963–981  ·  view source on GitHub ↗
(ptr)

Source from the content-addressed store, hash-verified

961
962
963function UTF32ToString(ptr) {
964 var i = 0;
965
966 var str = '';
967 while (1) {
968 var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
969 if (utf32 == 0)
970 return str;
971 ++i;
972 // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
973 // See http://unicode.org/faq/utf_bom.html#utf16-3
974 if (utf32 >= 0x10000) {
975 var ch = utf32 - 0x10000;
976 str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
977 } else {
978 str += String.fromCharCode(utf32);
979 }
980 }
981}
982
983
984// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…