mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 05:38:47 +02:00
src: use non-deprecated Utf8LengthV2() method
PR-URL: https://github.com/nodejs/node/pull/58070 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
parent
9aa1afb527
commit
0e68481bf8
5 changed files with 7 additions and 7 deletions
|
@ -21,7 +21,7 @@ void CallWithString(const FunctionCallbackInfo<Value>& args) {
|
|||
assert(args.Length() == 1 && args[0]->IsString());
|
||||
if (args.Length() == 1 && args[0]->IsString()) {
|
||||
Local<String> str = args[0].As<String>();
|
||||
const int32_t length = str->Utf8Length(args.GetIsolate()) + 1;
|
||||
const size_t length = str->Utf8LengthV2(args.GetIsolate()) + 1;
|
||||
char* buf = new char[length];
|
||||
str->WriteUtf8(args.GetIsolate(), buf, length);
|
||||
delete[] buf;
|
||||
|
|
|
@ -399,7 +399,7 @@ ByteSource ByteSource::FromStringOrBuffer(Environment* env,
|
|||
ByteSource ByteSource::FromString(Environment* env, Local<String> str,
|
||||
bool ntc) {
|
||||
CHECK(str->IsString());
|
||||
size_t size = str->Utf8Length(env->isolate());
|
||||
size_t size = str->Utf8LengthV2(env->isolate());
|
||||
size_t alloc_size = ntc ? size + 1 : size;
|
||||
auto out = DataPointer::Alloc(alloc_size);
|
||||
int opts = String::NO_OPTIONS;
|
||||
|
|
|
@ -122,7 +122,7 @@ void BindingData::EncodeUtf8String(const FunctionCallbackInfo<Value>& args) {
|
|||
CHECK(args[0]->IsString());
|
||||
|
||||
Local<String> str = args[0].As<String>();
|
||||
size_t length = str->Utf8Length(isolate);
|
||||
size_t length = str->Utf8LengthV2(isolate);
|
||||
|
||||
Local<ArrayBuffer> ab;
|
||||
{
|
||||
|
|
|
@ -2482,7 +2482,7 @@ napi_status NAPI_CDECL napi_get_value_string_utf8(
|
|||
|
||||
if (!buf) {
|
||||
CHECK_ARG(env, result);
|
||||
*result = val.As<v8::String>()->Utf8Length(env->isolate);
|
||||
*result = val.As<v8::String>()->Utf8LengthV2(env->isolate);
|
||||
} else if (bufsize != 0) {
|
||||
int copied = val.As<v8::String>()->WriteUtf8(
|
||||
env->isolate,
|
||||
|
|
|
@ -639,7 +639,7 @@ void Fill(const FunctionCallbackInfo<Value>& args) {
|
|||
// Can't use StringBytes::Write() in all cases. For example if attempting
|
||||
// to write a two byte character into a one byte Buffer.
|
||||
if (enc == UTF8) {
|
||||
str_length = str_obj->Utf8Length(env->isolate());
|
||||
str_length = str_obj->Utf8LengthV2(env->isolate());
|
||||
node::Utf8Value str(env->isolate(), args[1]);
|
||||
memcpy(ts_obj_data + start, *str, std::min(str_length, fill_length));
|
||||
|
||||
|
@ -727,8 +727,8 @@ void SlowByteLengthUtf8(const FunctionCallbackInfo<Value>& args) {
|
|||
CHECK(args[0]->IsString());
|
||||
|
||||
// Fast case: avoid StringBytes on UTF8 string. Jump to v8.
|
||||
args.GetReturnValue().Set(
|
||||
args[0].As<String>()->Utf8Length(args.GetIsolate()));
|
||||
size_t result = args[0].As<String>()->Utf8LengthV2(args.GetIsolate());
|
||||
args.GetReturnValue().Set(static_cast<uint64_t>(result));
|
||||
}
|
||||
|
||||
uint32_t FastByteLengthUtf8(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue