(str)
| 10 | let kSig_w_ii = makeSig([kWasmI32, kWasmI32], [kWasmStringRef]); |
| 11 | |
| 12 | function encodeWtf8(str) { |
| 13 | // String iterator coalesces surrogate pairs. |
| 14 | let out = []; |
| 15 | for (let codepoint of str) { |
| 16 | codepoint = codepoint.codePointAt(0); |
| 17 | if (codepoint <= 0x7f) { |
| 18 | out.push(codepoint); |
| 19 | } else if (codepoint <= 0x7ff) { |
| 20 | out.push(0xc0 | (codepoint >> 6)); |
| 21 | out.push(0x80 | (codepoint & 0x3f)); |
| 22 | } else if (codepoint <= 0xffff) { |
| 23 | out.push(0xe0 | (codepoint >> 12)); |
| 24 | out.push(0x80 | ((codepoint >> 6) & 0x3f)); |
| 25 | out.push(0x80 | (codepoint & 0x3f)); |
| 26 | } else if (codepoint <= 0x10ffff) { |
| 27 | out.push(0xf0 | (codepoint >> 18)); |
| 28 | out.push(0x80 | ((codepoint >> 12) & 0x3f)); |
| 29 | out.push(0x80 | ((codepoint >> 6) & 0x3f)); |
| 30 | out.push(0x80 | (codepoint & 0x3f)); |
| 31 | } else { |
| 32 | throw new Error("bad codepoint " + codepoint); |
| 33 | } |
| 34 | } |
| 35 | return out; |
| 36 | } |
| 37 | |
| 38 | let externalString = "I'm an external string"; |
| 39 | externalizeString(externalString); |
no test coverage detected