MCPcopy Create free account
hub / github.com/antimatter15/ocrad.js / UTF32ToString

Function UTF32ToString

ocrad.js:959–977  ·  view source on GitHub ↗
(ptr)

Source from the content-addressed store, hash-verified

957
958
959function UTF32ToString(ptr) {
960 var i = 0;
961
962 var str = '';
963 while (1) {
964 var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
965 if (utf32 == 0)
966 return str;
967 ++i;
968 // 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.
969 // See http://unicode.org/faq/utf_bom.html#utf16-3
970 if (utf32 >= 0x10000) {
971 var ch = utf32 - 0x10000;
972 str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
973 } else {
974 str += String.fromCharCode(utf32);
975 }
976 }
977}
978
979
980// 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