UNPKG

pasm

Version:

Piston X86-64 Assembler

28 lines (25 loc) 840 B
var toUTF8Array; toUTF8Array = function(str) { var charcode, i, utf8; utf8 = []; i = 0; while (i < str.length) { charcode = str.charCodeAt(i); if (charcode < 0x80) { utf8.push(charcode); } else if (charcode < 0x800) { utf8.push(0xc0 | (charcode >> 6), 0x80 | (charcode & 0x3f)); } else if (charcode < 0xd800 || charcode >= 0xe000) { utf8.push(0xe0 | (charcode >> 12), 0x80 | ((charcode >> 6) & 0x3f), 0x80 | (charcode & 0x3f)); } else { i++; charcode = ((charcode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff); utf8.push(0xf0 | (charcode >> 18), 0x80 | ((charcode >> 12) & 0x3f), 0x80 | ((charcode >> 6) & 0x3f), 0x80 | (charcode & 0x3f)); } i++; } return utf8; }; if (typeof exports !== "undefined" && exports !== null) { exports.toUTF8Array = toUTF8Array; }