Add String.fromUTF8 helper (see #291); Update dist files

This commit is contained in:
dcodeIO
2018-10-03 00:49:56 +02:00
parent 53b030fed5
commit b7e7be20cf
9 changed files with 5344 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ var len = str.lengthUTF8;
assert(len == 11);
var ptr = str.toUTF8();
var ptr = str.toUTF8(); // toUTF8 is zero-terminated
assert(load<u8>(ptr, 0) == 0xf0);
assert(load<u8>(ptr, 1) == 0x90);
@ -20,4 +20,11 @@ assert(load<u8>(ptr, 8) == 0xad);
assert(load<u8>(ptr, 9) == 0xa2);
assert(load<u8>(ptr, 10) == 0);
assert(String.fromUTF8(ptr, 0) == ""); // fromUTF8 is not zero-terminated
assert(String.fromUTF8(ptr, len - 1) == str);
assert(String.fromUTF8(ptr, 4) == "𐐷");
assert(String.fromUTF8(ptr + 4, 2) == "hi");
assert(String.fromUTF8(ptr + 6, 4) == "𤭢");
assert(String.fromUTF8(ptr + 10, 1) == "\0");
memory.free(ptr);

File diff suppressed because it is too large Load Diff

View File

@ -3749,7 +3749,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 523)
(i32.const 566)
(i32.const 10)
)
(unreachable)

View File

@ -4536,7 +4536,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 523)
(i32.const 566)
(i32.const 10)
)
(unreachable)