Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,17 @@ size_t StringBytes::Write(Isolate* isolate,

case BUFFER:
case UTF8:
nbytes = str->WriteUtf8V2(
isolate, buf, buflen, String::WriteFlags::kReplaceInvalidUtf8);
if (input_view.is_one_byte()) {
// Use simdutf for one-byte strings instead of V8's WriteUtf8V2.
nbytes = simdutf::convert_latin1_to_utf8_safe(
reinterpret_cast<const char*>(input_view.data8()),
input_view.length(),
buf,
buflen);
} else {
nbytes = str->WriteUtf8V2(
isolate, buf, buflen, String::WriteFlags::kReplaceInvalidUtf8);
}
break;

case UCS2: {
Expand Down
Loading