fix(iOS): jsi convert Chinese string error

This commit is contained in:
bennyzqliu
2022-11-01 10:06:49 +08:00
committed by luomy
parent df9a3c4fd8
commit 6a34069bc4
2 changed files with 4 additions and 2 deletions
@@ -81,7 +81,7 @@ HIPPY_EXPORT_TURBO_METHOD(nativeWithPromise:(nullable id)params
if (self = [super init]) {
self.enableVideo = YES;
self.videoInfo = @{@"a": @"1"};
self.strInfo = @"It is a default string!";
self.strInfo = @"测试一下,It is a default string!";
}
return self;
}
+3 -1
View File
@@ -155,7 +155,9 @@ static std::shared_ptr<napi::CtxValue> convertObjcObjectToCtxValue(const std::sh
std::shared_ptr<napi::CtxValue> result;
if ([objcObject isKindOfClass:[NSString class]]) {
result = context->CreateString([((NSString *)objcObject) UTF8String]);
std::string str = [((NSString *)objcObject) UTF8String];
unicode_string_view str_view(StringViewUtils::ToU8Pointer(str.c_str()));
result = context->CreateString(str_view);
} else if ([objcObject isKindOfClass:[NSNumber class]]) {
if ([objcObject isKindOfClass:[@YES class]]) {
result = context->CreateBoolean(((NSNumber *)objcObject).boolValue);