Skip to content

Commit c85f1df

Browse files
committed
src: fix endianness of simdutf
1 parent 25ff0f8 commit c85f1df

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
@@ -256,10 +256,10 @@ bool BuiltinLoader::Add(const char* id, std::string_view utf8source) {
256256
size_t expected_u16_length =
257257
simdutf::utf16_length_from_utf8(utf8source.data(), utf8source.length());
258258
auto out = std::make_shared<std::vector<uint16_t>>(expected_u16_length);
259-
size_t u16_length = simdutf::convert_utf8_to_utf16le(
260-
utf8source.data(),
261-
utf8source.length(),
262-
reinterpret_cast<char16_t*>(out->data()));
259+
size_t u16_length =
260+
simdutf::convert_utf8_to_utf16(utf8source.data(),
261+
utf8source.length(),
262+
reinterpret_cast<char16_t*>(out->data()));
263263
out->resize(u16_length);
264264
return Add(id, UnionBytes(out));
265265
}

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)