From 03e42707d242f763066cfbfe73317c96f7b2df14 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 31 Jul 2024 18:49:53 +0800 Subject: [PATCH] Revert --- native/cocos/bindings/jswrapper/v8/Utils.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/native/cocos/bindings/jswrapper/v8/Utils.cpp b/native/cocos/bindings/jswrapper/v8/Utils.cpp index 1a2453f9074..6e5334253fa 100644 --- a/native/cocos/bindings/jswrapper/v8/Utils.cpp +++ b/native/cocos/bindings/jswrapper/v8/Utils.cpp @@ -33,24 +33,11 @@ #include "ScriptEngine.h" #include "base/Log.h" #include "base/Macros.h" - #include "base/UTF8.h" namespace se { namespace internal { -namespace { - -inline v8::MaybeLocal createV8StringFromUtf8(v8::Isolate* isolate, const ccstd::string &u8Str, v8::NewStringType type = v8::NewStringType::kNormal) { - std::u16string u16Str; - if (cc::StringUtils::UTF8ToUTF16(u8Str, u16Str)) { - return v8::String::NewFromTwoByte(isolate, reinterpret_cast(u16Str.data()), type, static_cast(u16Str.length())); - } - return {}; -} - -} // namespace { - void jsToSeArgs(const v8::FunctionCallbackInfo &v8args, ValueArray &outArr) { v8::Isolate *isolate = v8args.GetIsolate(); for (int i = 0; i < v8args.Length(); i++) { @@ -75,8 +62,7 @@ void seToJsValue(v8::Isolate *isolate, const Value &v, v8::Local *out *outJsVal = v8::Number::New(isolate, v.toDouble()); break; case Value::Type::String: { -// v8::MaybeLocal str = v8::String::NewFromUtf8(isolate, v.toString().data(), v8::NewStringType::kNormal, static_cast(v.toString().length())); - auto str = createV8StringFromUtf8(isolate, v.toString(), v8::NewStringType::kNormal); + v8::MaybeLocal str = v8::String::NewFromUtf8(isolate, v.toString().data(), v8::NewStringType::kNormal, static_cast(v.toString().length())); if (!str.IsEmpty()) { *outJsVal = str.ToLocalChecked(); } else { @@ -195,8 +181,7 @@ void setReturnValueTemplate(const Value &data, const T &argv) { break; } case Value::Type::String: { -// v8::MaybeLocal value = v8::String::NewFromUtf8(argv.GetIsolate(), data.toString().c_str(), v8::NewStringType::kNormal); - auto value = createV8StringFromUtf8(argv.GetIsolate(), data.toString(), v8::NewStringType::kNormal); + v8::MaybeLocal value = v8::String::NewFromUtf8(argv.GetIsolate(), data.toString().c_str(), v8::NewStringType::kNormal); CC_ASSERT(!value.IsEmpty()); argv.GetReturnValue().Set(value.ToLocalChecked()); break;