src: fix to use replacement character
PR-URL: https://github.com/nodejs/node/pull/43999 Fixes: https://github.com/nodejs/node/issues/43962 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Feng Yu <F3n67u@outlook.com>
This commit is contained in:
parent
28a9042ee6
commit
e5add6659d
@ -425,7 +425,11 @@ void ConverterObject::Create(const FunctionCallbackInfo<Value>& args) {
|
||||
nullptr, nullptr, nullptr, &status);
|
||||
}
|
||||
|
||||
new ConverterObject(env, obj, conv, flags);
|
||||
auto converter = new ConverterObject(env, obj, conv, flags);
|
||||
size_t sublen = ucnv_getMinCharSize(conv);
|
||||
std::string sub(sublen, '?');
|
||||
converter->set_subst_chars(sub.c_str());
|
||||
|
||||
args.GetReturnValue().Set(obj);
|
||||
}
|
||||
|
||||
|
@ -199,3 +199,10 @@ if (common.hasIntl) {
|
||||
const str = decoder.decode(chunk);
|
||||
assert.strictEqual(str, 'foo\ufffd');
|
||||
}
|
||||
|
||||
if (common.hasIntl) {
|
||||
const decoder = new TextDecoder('Shift_JIS');
|
||||
const chunk = new Uint8Array([-1]);
|
||||
const str = decoder.decode(chunk);
|
||||
assert.strictEqual(str, '\ufffd');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user