mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 06:21:29 +00:00
Add String.fromUTF8 helper (see #291); Update dist files
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -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
@ -3749,7 +3749,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 80)
|
||||
(i32.const 523)
|
||||
(i32.const 566)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -4536,7 +4536,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 80)
|
||||
(i32.const 523)
|
||||
(i32.const 566)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
|
Reference in New Issue
Block a user