Skip to content

Commit 646cadc

Browse files
anonrigjuanarbol
authored andcommitted
src: fix endianness of simdutf
PR-URL: #46257 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent b7fe8c7 commit 646cadc

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

src/node_builtins.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ bool BuiltinLoader::Add(const char* id, std::string_view utf8source) {
253253
size_t expected_u16_length =
254254
simdutf::utf16_length_from_utf8(utf8source.data(), utf8source.length());
255255
auto out = std::make_shared<std::vector<uint16_t>>(expected_u16_length);
256-
size_t u16_length = simdutf::convert_utf8_to_utf16le(
257-
utf8source.data(),
258-
utf8source.length(),
259-
reinterpret_cast<char16_t*>(out->data()));
256+
size_t u16_length =
257+
simdutf::convert_utf8_to_utf16(utf8source.data(),
258+
utf8source.length(),
259+
reinterpret_cast<char16_t*>(out->data()));
260260
out->resize(u16_length);
261261
return Add(id, UnionBytes(out));
262262
}

test/cctest/test_util.cc

-14
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,3 @@ TEST(UtilTest, SPrintF) {
299299
const std::string with_zero = std::string("a") + '\0' + 'b';
300300
EXPECT_EQ(SPrintF("%s", with_zero), with_zero);
301301
}
302-
303-
TEST(UtilTest, SimdutfEndiannessDoesNotMeanEndianness) {
304-
// In simdutf, "LE" does *not* refer to Little Endian, it refers
305-
// to 16-byte code units that are stored using *host* endianness.
306-
// This is weird and confusing naming, and so we add this assertion
307-
// here to verify that this is actually the case (so that CI tells
308-
// us if it changed, because for most people Little Endian is
309-
// host endianness, so locally everything would work fine).
310-
const char utf8source[] = "\xe7\x8c\xab";
311-
char16_t u16output;
312-
size_t u16len = simdutf::convert_utf8_to_utf16le(utf8source, 3, &u16output);
313-
EXPECT_EQ(u16len, 1u);
314-
EXPECT_EQ(u16output, 0x732B);
315-
}

0 commit comments

Comments
 (0)