@@ -425,7 +425,11 @@ void ConverterObject::Create(const FunctionCallbackInfo<Value>& args) {
425
425
nullptr , nullptr , nullptr , &status);
426
426
}
427
427
428
- new ConverterObject (env, obj, conv, flags);
428
+ auto converter = new ConverterObject (env, obj, conv, flags);
429
+ size_t sublen = ucnv_getMinCharSize (conv);
430
+ std::string sub (sublen, ' ?' );
431
+ converter->set_subst_chars (sub.c_str ());
432
+
429
433
args.GetReturnValue ().Set (obj);
430
434
}
431
435
@@ -473,6 +477,11 @@ void ConverterObject::Decode(const FunctionCallbackInfo<Value>& args) {
473
477
size_t source_length = input.length ();
474
478
475
479
UChar* target = *result;
480
+ // printf("source c: %c\n", *source);
481
+ // printf("source d: %d\n", *source);
482
+ // printf("source s: %s\n", source);
483
+ // printf("source_length: %zu\n", source_length);
484
+ // printf("limit: %zu\n", limit);
476
485
ucnv_toUnicode (converter->conv (),
477
486
&target,
478
487
target + limit,
@@ -485,6 +494,7 @@ void ConverterObject::Decode(const FunctionCallbackInfo<Value>& args) {
485
494
if (U_SUCCESS (status)) {
486
495
bool omit_initial_bom = false ;
487
496
if (limit > 0 ) {
497
+ // printf("result[0]: %d\n", result[0]);
488
498
result.SetLength (target - &result[0 ]);
489
499
if (result.length () > 0 &&
490
500
converter->unicode () &&
0 commit comments