@@ -200,8 +200,11 @@ MaybeLocal<Value> ExternTwoByteString::NewSimpleFromCopy(Isolate* isolate,
200200
201201} // anonymous namespace
202202
203- size_t StringBytes::WriteUCS2 (
204- Isolate* isolate, char * buf, size_t buflen, Local<String> str, int flags) {
203+ size_t StringBytes::WriteUCS2 (Isolate* isolate,
204+ char * buf,
205+ size_t buflen,
206+ Local<String> str,
207+ int flags = String::WriteFlags::kNone ) {
205208 uint16_t * const dst = reinterpret_cast <uint16_t *>(buf);
206209
207210 size_t max_chars = buflen / sizeof (*dst);
@@ -212,7 +215,8 @@ size_t StringBytes::WriteUCS2(
212215 uint16_t * const aligned_dst = nbytes::AlignUp (dst, sizeof (*dst));
213216 size_t nchars;
214217 if (aligned_dst == dst) {
215- nchars = str->Write (isolate, dst, 0 , max_chars, flags);
218+ nchars = max_chars;
219+ str->WriteV2 (isolate, 0 , nchars, dst, flags);
216220 return nchars * sizeof (*dst);
217221 }
218222
@@ -223,15 +227,15 @@ size_t StringBytes::WriteUCS2(
223227 if (max_chars == 0 ) {
224228 return 0 ;
225229 }
226- nchars = str-> Write (isolate, aligned_dst, 0 , max_chars - 1 , flags) ;
227- CHECK_EQ (nchars, max_chars - 1 );
230+ nchars = max_chars - 1 ;
231+ str-> WriteV2 (isolate, 0 , nchars, aligned_dst, flags );
228232
229233 // Shift everything to unaligned-left
230234 memmove (dst, aligned_dst, nchars * sizeof (*dst));
231235
232236 // One more char to be written
233237 uint16_t last;
234- CHECK_EQ ( str->Write (isolate, &last, nchars, 1 , flags), 1 );
238+ str->WriteV2 (isolate, nchars, 1 , &last, flags );
235239 memcpy (buf + nchars * sizeof (*dst), &last, sizeof (last));
236240 nchars++;
237241
@@ -250,9 +254,7 @@ size_t StringBytes::Write(Isolate* isolate,
250254 Local<String> str = val.As <String>();
251255 String::ValueView input_view (isolate, str);
252256
253- int flags = String::HINT_MANY_WRITES_EXPECTED |
254- String::NO_NULL_TERMINATION |
255- String::REPLACE_INVALID_UTF8;
257+ int flags = String::WriteFlags::kReplaceInvalidUtf8 ;
256258
257259 switch (encoding) {
258260 case ASCII:
@@ -262,13 +264,14 @@ size_t StringBytes::Write(Isolate* isolate,
262264 memcpy (buf, input_view.data8 (), nbytes);
263265 } else {
264266 uint8_t * const dst = reinterpret_cast <uint8_t *>(buf);
265- nbytes = str->WriteOneByte (isolate, dst, 0 , buflen, flags);
267+ str->WriteOneByteV2 (isolate, 0 , buflen, dst, flags);
268+ nbytes = buflen;
266269 }
267270 break ;
268271
269272 case BUFFER:
270273 case UTF8:
271- nbytes = str->WriteUtf8 (isolate, buf, buflen, nullptr , flags);
274+ nbytes = str->WriteUtf8V2 (isolate, buf, buflen, flags);
272275 break ;
273276
274277 case UCS2: {
0 commit comments