| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5f44ce8 commit 332b035
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ void CallWithString(const FunctionCallbackInfo<Value>& args) { | |||
| 19 | 19 | assert(args.Length() == 1 && args[0]->IsString()); | |
| 20 | 20 | if (args.Length() == 1 && args[0]->IsString()) { | |
| 21 | 21 | Local<String> str = args[0].As<String>(); | |
| 22 | - const int32_t length = str->Utf8Length() + 1; | ||
| 22 | + const int32_t length = str->Utf8Length(args.GetIsolate()) + 1; | ||
| 23 | 23 | char* buf = new char[length]; | |
| 24 | 24 | str->WriteUtf8(args.GetIsolate(), buf, length); | |
| 25 | 25 | delete [] buf; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2399,7 +2399,7 @@ napi_status napi_get_value_string_utf8(napi_env env, | |||
| 2399 | 2399 | ||
| 2400 | 2400 | if (!buf) { | |
| 2401 | 2401 | CHECK_ARG(env, result); | |
| 2402 | - *result = val.As<v8::String>()->Utf8Length(); | ||
| 2402 | + *result = val.As<v8::String>()->Utf8Length(env->isolate); | ||
| 2403 | 2403 | } else { | |
| 2404 | 2404 | int copied = val.As<v8::String>()->WriteUtf8( | |
| 2405 | 2405 | env->isolate, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -599,7 +599,7 @@ void Fill(const FunctionCallbackInfo<Value>& args) { | |||
| 599 | 599 | // Can't use StringBytes::Write() in all cases. For example if attempting | |
| 600 | 600 | // to write a two byte character into a one byte Buffer. | |
| 601 | 601 | if (enc == UTF8) { | |
| 602 | - str_length = str_obj->Utf8Length(); | ||
| 602 | + str_length = str_obj->Utf8Length(env->isolate()); | ||
| 603 | 603 | node::Utf8Value str(env->isolate(), args[1]); | |
| 604 | 604 | memcpy(ts_obj_data + start, *str, MIN(str_length, fill_length)); | |
| 605 | 605 | ||
@@ -689,10 +689,11 @@ void StringWrite(const FunctionCallbackInfo<Value>& args) { | |||
| 689 | 689 | } | |
| 690 | 690 | ||
| 691 | 691 | void ByteLengthUtf8(const FunctionCallbackInfo<Value> &args) { | |
| 692 | + Environment* env = Environment::GetCurrent(args); | ||
| 692 | 693 | CHECK(args[0]->IsString()); | |
| 693 | 694 | ||
| 694 | 695 | // Fast case: avoid StringBytes on UTF8 string. Jump to v8. | |
| 695 | - args.GetReturnValue().Set(args[0].As<String>()->Utf8Length()); | ||
| 696 | + args.GetReturnValue().Set(args[0].As<String>()->Utf8Length(env->isolate())); | ||
| 696 | 697 | } | |
| 697 | 698 | ||
| 698 | 699 | // Normalize val to be an integer in the range of [1, -1] since | |
@@ -1062,7 +1063,7 @@ static void EncodeUtf8String(const FunctionCallbackInfo<Value>& args) { | |||
| 1062 | 1063 | CHECK(args[0]->IsString()); | |
| 1063 | 1064 | ||
| 1064 | 1065 | Local<String> str = args[0].As<String>(); | |
| 1065 | - size_t length = str->Utf8Length(); | ||
| 1066 | + size_t length = str->Utf8Length(isolate); | ||
| 1066 | 1067 | char* data = node::UncheckedMalloc(length); | |
| 1067 | 1068 | str->WriteUtf8(isolate, | |
| 1068 | 1069 | data, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -465,7 +465,7 @@ size_t StringBytes::Size(Isolate* isolate, | |||
| 465 | 465 | ||
| 466 | 466 | case BUFFER: | |
| 467 | 467 | case UTF8: | |
| 468 | - return str->Utf8Length(); | ||
| 468 | + return str->Utf8Length(isolate); | ||
| 469 | 469 | ||
| 470 | 470 | case UCS2: | |
| 471 | 471 | return str->Length() * sizeof(uint16_t); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments