Skip to content

Commit 4fac9c8

Browse files
hryhoriiK97meta-codesync[bot]
authored andcommitted
Convert NSStrings returned to JS to UTF-8 only once (#59325)
Summary: On iOS, every `NSString` a TurboModule returns to JS goes through `convertNSStringToJSIString` (`ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm`). That covers promise results, callbacks, and every string key and value inside returned objects. It also covers the body of every `fetch(...).text()` and `.json()` response, which RN reads through `FileReader`. **Current behavior.** - The function calls `UTF8String` twice, once to check it against `nullptr` and once for the value. - It copies the result into a temporary `std::string` for `jsi::String::createFromUtf8`, which measures it with `strlen`. - For any string that isn't stored as ASCII, such as one with accented letters or an emoji, each `UTF8String` call converts the whole string to UTF-8, and Hermes then converts it back to UTF-16. For a 1 MB JSON response with accented letters this takes about 7 ms on the JS thread. - Because the length comes from `strlen`, a string with a `\0` character is cut off at it. - A string with a lone surrogate, which `UTF8String` can't encode, arrives as `""`. **With this change.** - Strings stored as ASCII are passed as they are (`CFStringGetCStringPtr` → `createFromAscii`). - Other strings pass their own UTF-16 characters (`CFStringGetCharactersPtr` → `createFromUtf16`), which Hermes stores without converting. - If CoreFoundation can't expose either pointer, the characters are copied once with `CFStringGetCharacters` and passed as UTF-16. - `JSCRuntime` gets a native `createStringFromUtf16` (`JSStringCreateWithCharacters`). Before, JSC used JSI's default, which escapes every character as `\uXXXX` and calls `eval`. Every string converts to the same JS string as before, with two exceptions: - A `\0` no longer truncates strings passed as UTF-16. This fixes, on iOS, the native → JS side of #24129, which #57906 fixed for JS → native. On Hermes this covers every string; on JSC, strings stored as ASCII still stop at the `\0` inside JSC's own `createFromAscii`. - Side effect: a native module that builds a string from a zero-padded C buffer (for example a fixed-size device name) now shows the trailing `\0` characters in JS instead of a cut-off string. - A lone surrogate is kept instead of turning the string into `""`. ## Changelog: [IOS] [FIXED] - Strings returned from native modules to JS convert faster, are no longer truncated at a `\0` character, and are no longer replaced with an empty string when they contain a lone surrogate Pull Request resolved: #59325 Test Plan: ## Validation - Apple simulator builds passed: ```sh buck2 build fbsource//fbobjc/mode/od-ios fbsource//fbobjc/mode/iphonesimulator \ fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/react/nativemodule/core:coreApple \ fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/jsc:JSCRuntimeApple ``` - Native tests: **68 passed, 0 failed, 0 skipped**: ```sh buck2 test fbsource//fbobjc/mode/od-ios fbsource//fbobjc/mode/iphonesimulator \ fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/react/nativemodule/core:iostestsApple \ fbsource//xplat/jsi:JSITests-SystemJSCApple ``` https://www.internalfb.com/intern/testinfra/testrun/2251800222410062 These are the existing core/JSI suites, not the RNTester string-conversion suite below. JSI's `CreateFromUtf16Test` forces the default implementation rather than directly testing the JSC override. - Nil guard regression: `python3 /tmp/D126905172-null-regression.py` compiled the exact Objective-C++ helper with instrumented CoreFoundation/JSI stubs. Nil returns an empty string with zero CF calls; removing only the guard aborts on the null CF argument. This is isolated guard coverage, not a real-runtime integration test. - Meta-managed clang-format checked all three C++/Objective-C++ sources successfully. `arc lint -a` and draft submission validation passed. Targeted extended Clang-Tidy has no new cast/style findings; it still reports two warnings in unchanged promise-handling code. - Full `arc lint -e extra` could not pass RNFORMAT because this checkout lacks the `tinyglobby` module used by the formatter wrapper. The RNTester XCTest file has no internal Buck compilation database; its original simulator results are retained below. - Independent expert review: no critical findings. ## Non-nil integration and performance evidence The previously recorded validation below remains applicable to the non-nil conversion paths; those measurements and the RNTester simulator suite were not rerun during this validation. - **`RCTTurboModuleStringConversionTests`** (new, `RNTesterUnitTests`, run by `yarn test-ios`). - Each test converts strings through `TurboModuleConvertUtils::convertObjCObjectToJSIValue` with a Hermes runtime and checks that the JS string has the same UTF-16 code units. - Each test also checks which branch its input takes: ASCII pointer, UTF-16 pointer, or copy (a tagged-pointer string and an `NSString` subclass). - Inputs: ASCII, non-ASCII text (Polish, Japanese) and emoji, empty and large strings, strings with a `\0` (including one with an ASCII pointer), and strings with a lone surrogate (with and without a UTF-16 pointer). - All 10 pass on an iPhone simulator, three runs in a row. With the old function, the `\0` and both lone-surrogate tests fail and the other 7 pass. - The pinned `clang-format` (`scripts/clang-format.js --check`) passes on all three files. - **JSC:** a macOS program built with the system JavaScriptCore and this PR's `JSCRuntime.cpp` and `jsi.cpp` converts ASCII, Polish, CJK with emoji, empty, `\0` and lone-surrogate strings with the new function and reads every character back in JS. All of them match. With the old function, the `\0` and lone-surrogate strings don't. Speed on JSC, old function → new function, median of 9 rounds: accented letters and emoji −86% at 128 characters and −98% to −99% from 1 KB to 1 MB (1 MB: 4.1 ms → 26 µs); ASCII −24% to −33%. - **Measurement on a physical iPhone 15 Pro (iOS 26.6.1)** with Hermes, RNTester built with `xcodebuild` in Release, at sizes from 16 characters to 1 MB. - Inputs: JSON-like text in ASCII, with accented letters (such as ż, ó, é), and with emoji, created from UTF-8 data the way strings from the network or files arrive. - **Conversion alone:** the old function and this PR's function run in turn in the app on the phone, with a Hermes runtime, converting the same string in a loop. Each value is the median of 15 rounds, averaged over two launches; the two launches agree within 3 points. Both functions return the same JS string for every input. - **`readAsText` in JS:** the same binary with the conversion switched by a launch environment variable, in two cycles of before, after, after, before, following a warmup launch. Each value is the median of 500 reads (60 for 1 MB, first 2 left out as warmups), averaged over the four launches per arm. Every read returned the original string in both arms. Conversion alone, time per string: | Size | ASCII | Accented letters | Emoji | |---|--:|--:|--:| | 16 characters* | 0.088 → 0.043 µs (−52%) | 0.088 → 0.044 µs (−50%) | 0.089 → 0.044 µs (−50%) | | 128 characters | 0.11 → 0.04 µs (−64%) | 0.93 → 0.07 µs (−92%) | 0.92 → 0.07 µs (−92%) | | 1 KB | 0.19 → 0.06 µs (−68%) | 7.7 → 0.09 µs (−99%) | 7.2 → 0.10 µs (−99%) | | 10 KB | 0.92 → 0.20 µs (−78%) | 72 → 0.55 µs (−99%) | 67 → 0.65 µs (−99%) | | 100 KB | 9.1 → 2.3 µs (−74%) | 704 → 2.6 µs (−99.6%) | 663 → 2.7 µs (−99.6%) | | 1 MB | 86 → 20 µs (−77%) | 7.18 ms → 47 µs (−99.3%) | 6.67 ms → 41 µs (−99.4%) | \* At 16 characters, the text from the start of the JSON is still ASCII in all three inputs. `FileReader.readAsText` in JS (the path `fetch`'s `text()` and `json()` take), median per read: | Size | ASCII | Accented letters | Emoji | |---|--:|--:|--:| | 1 KB | 79 µs → 78 µs | 55 µs → 47 µs (−15%) | 45 µs → 38 µs (−17%) | | 10 KB | 37 µs → 36 µs | 137 µs → 68 µs (−51%) | 133 µs → 67 µs (−50%) | | 100 KB | 65 µs → 59 µs (−9%) | 1,010 µs → 334 µs (−67%) | 979 µs → 331 µs (−66%) | | 1 MB | 186 µs → 134 µs (−28%) | 9.96 ms → 3.03 ms (−70%) | 9.62 ms → 3.00 ms (−69%) | At 1 KB, a `readAsText` call is mostly the fixed cost of the module call and the promise, so the gain there is smaller. The 1 KB ASCII input is the first one read in each launch, so its time also includes warmup. - **Real `fetch` calls.** I also profiled RNTester (Release, before this change) with Time Profiler on the same iPhone while it fetched 10 KB to 1 MB JSON files from a local HTTP server over Wi-Fi with `.text()` and `.json()`. `convertNSStringToJSIString` was about 29% of all JS-thread time, the largest React Native cost on that thread, and Hermes converting that UTF-8 back to UTF-16 was another 12%. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed By: cipolleschi Differential Revision: D126905172 Pulled By: javache fbshipit-source-id: 81b5a914001ba1f6de67bb4604a0ec57cbbcad32
1 parent 5e13324 commit 4fac9c8

4 files changed

Lines changed: 229 additions & 1 deletion

File tree

‎packages/react-native/ReactCommon/jsc/JSCRuntime.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ class JSCRuntime : public jsi::Runtime {
178178

179179
jsi::String createStringFromAscii(const char* str, size_t length) override;
180180
jsi::String createStringFromUtf8(const uint8_t* utf8, size_t length) override;
181+
jsi::String createStringFromUtf16(const char16_t* utf16, size_t length)
182+
override;
181183
std::string utf8(const jsi::String& /*str*/) override;
182184
size_t length(const jsi::String& /*str*/) override;
183185

@@ -742,6 +744,18 @@ jsi::String JSCRuntime::createStringFromUtf8(
742744
return result;
743745
}
744746

747+
jsi::String JSCRuntime::createStringFromUtf16(
748+
const char16_t* utf16,
749+
size_t length) {
750+
JSStringRef stringRef = JSStringCreateWithCharacters(
751+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
752+
reinterpret_cast<const JSChar*>(utf16),
753+
length);
754+
auto result = createString(stringRef);
755+
JSStringRelease(stringRef);
756+
return result;
757+
}
758+
745759
std::string JSCRuntime::utf8(const jsi::String& str) {
746760
return JSStringToSTLString(stringRef(str));
747761
}

‎packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#import <mutex>
3131

3232
#import <sstream>
33+
#import <string>
3334
#import <vector>
3435

3536
using namespace facebook;
@@ -60,7 +61,28 @@ static int32_t getUniqueId()
6061

6162
static jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *value)
6263
{
63-
return jsi::String::createFromUtf8(runtime, ([value UTF8String] != nullptr) ? [value UTF8String] : "");
64+
if (value == nil) {
65+
return jsi::String::createFromAscii(runtime, "", 0);
66+
}
67+
68+
// Hand the JS runtime the string's own ASCII or UTF-16 characters when
69+
// CoreFoundation can expose them, and copy them once otherwise.
70+
auto string = (__bridge CFStringRef)value;
71+
CFIndex length = CFStringGetLength(string);
72+
if (const char *ascii = CFStringGetCStringPtr(string, kCFStringEncodingASCII)) {
73+
return jsi::String::createFromAscii(runtime, ascii, static_cast<size_t>(length));
74+
}
75+
if (const UniChar *characters = CFStringGetCharactersPtr(string)) {
76+
return jsi::String::createFromUtf16(
77+
runtime,
78+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
79+
reinterpret_cast<const char16_t *>(characters),
80+
static_cast<size_t>(length));
81+
}
82+
std::u16string utf16(length, u'\0');
83+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
84+
CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(utf16.data()));
85+
return jsi::String::createFromUtf16(runtime, utf16);
6486
}
6587

6688
static jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value)

‎packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB218B22B41FCD005AC45F /* XCTest.framework */; };
5555
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */; };
5656
F1A0B1C23D4E5F6071829302 /* RCTTurboModuleArrayBufferTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F1A0B1C23D4E5F6071829301 /* RCTTurboModuleArrayBufferTests.mm */; };
57+
F1A0B1C23D4E5F6071829322 /* RCTTurboModuleStringConversionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F1A0B1C23D4E5F6071829321 /* RCTTurboModuleStringConversionTests.mm */; };
5758
D1A60AD11B9247A080734F02 /* RCTDevLoadingViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D1A60AD11B9247A080734F01 /* RCTDevLoadingViewTests.m */; };
5859
/* End PBXBuildFile section */
5960

@@ -160,6 +161,7 @@
160161
E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_DIR; };
161162
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
162163
F1A0B1C23D4E5F6071829301 /* RCTTurboModuleArrayBufferTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTTurboModuleArrayBufferTests.mm; sourceTree = "<group>"; };
164+
F1A0B1C23D4E5F6071829321 /* RCTTurboModuleStringConversionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTTurboModuleStringConversionTests.mm; sourceTree = "<group>"; };
163165
D1A60AD11B9247A080734F01 /* RCTDevLoadingViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTDevLoadingViewTests.m; sourceTree = "<group>"; };
164166
/* End PBXFileReference section */
165167

@@ -339,6 +341,7 @@
339341
E7DB20C322B2BAA4005AC45F /* RCTMethodArgumentTests.m */,
340342
E7DB20CB22B2BAA5005AC45F /* RCTModuleMethodTests.mm */,
341343
F1A0B1C23D4E5F6071829301 /* RCTTurboModuleArrayBufferTests.mm */,
344+
F1A0B1C23D4E5F6071829321 /* RCTTurboModuleStringConversionTests.mm */,
342345
E7DB20CF22B2BAA5005AC45F /* RCTMultipartStreamReaderTests.m */,
343346
A975CA6B2C05EADE0043F72A /* RCTNetworkTaskTests.m */,
344347
E7DB20BE22B2BAA4005AC45F /* RCTNativeAnimatedNodesManagerTests.m */,
@@ -755,6 +758,7 @@
755758
E7DB20E022B2BAA6005AC45F /* RCTMethodArgumentTests.m in Sources */,
756759
E7DB20E822B2BAA6005AC45F /* RCTModuleMethodTests.mm in Sources */,
757760
F1A0B1C23D4E5F6071829302 /* RCTTurboModuleArrayBufferTests.mm in Sources */,
761+
F1A0B1C23D4E5F6071829322 /* RCTTurboModuleStringConversionTests.mm in Sources */,
758762
E7DB20E222B2BAA6005AC45F /* RCTGzipTests.m in Sources */,
759763
E7DB20ED22B2BAA6005AC45F /* RCTURLUtilsTests.m in Sources */,
760764
E7DB20D322B2BAA6005AC45F /* RCTBlobManagerTests.m in Sources */,
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#import <XCTest/XCTest.h>
9+
10+
#import <ReactCommon/RCTTurboModule.h>
11+
#import <hermes/hermes.h>
12+
13+
#import <memory>
14+
#import <string>
15+
#import <vector>
16+
17+
using namespace facebook;
18+
using facebook::react::TurboModuleConvertUtils::convertObjCObjectToJSIValue;
19+
20+
// An NSString subclass that only implements the primitive methods, so
21+
// CoreFoundation can't hand out a pointer to its characters.
22+
@interface RCTTurboModuleStringConversionTestsString : NSString
23+
- (instancetype)initWithCharacters:(std::vector<unichar>)characters;
24+
@end
25+
26+
@implementation RCTTurboModuleStringConversionTestsString {
27+
std::vector<unichar> _characters;
28+
}
29+
30+
- (instancetype)initWithCharacters:(std::vector<unichar>)characters
31+
{
32+
if (self = [super init]) {
33+
_characters = std::move(characters);
34+
}
35+
return self;
36+
}
37+
38+
- (NSUInteger)length
39+
{
40+
return _characters.size();
41+
}
42+
43+
- (unichar)characterAtIndex:(NSUInteger)index
44+
{
45+
return _characters[index];
46+
}
47+
48+
@end
49+
50+
namespace {
51+
52+
std::u16string utf16FromNSString(NSString *string)
53+
{
54+
std::u16string utf16(string.length, u'\0');
55+
[string getCharacters:reinterpret_cast<unichar *>(utf16.data()) range:NSMakeRange(0, string.length)];
56+
return utf16;
57+
}
58+
59+
// Strings read from data, like the text that `FileReader` returns.
60+
NSString *stringFromUTF8Data(NSString *string)
61+
{
62+
return [[NSString alloc] initWithData:[string dataUsingEncoding:NSUTF8StringEncoding] encoding:NSUTF8StringEncoding];
63+
}
64+
65+
NSString *stringWithCharacters(std::vector<unichar> characters)
66+
{
67+
return [NSString stringWithCharacters:characters.data() length:characters.size()];
68+
}
69+
70+
bool hasASCIIPointer(NSString *string)
71+
{
72+
return CFStringGetCStringPtr((__bridge CFStringRef)string, kCFStringEncodingASCII) != nullptr;
73+
}
74+
75+
bool hasUTF16Pointer(NSString *string)
76+
{
77+
return CFStringGetCharactersPtr((__bridge CFStringRef)string) != nullptr;
78+
}
79+
80+
} // namespace
81+
82+
@interface RCTTurboModuleStringConversionTests : XCTestCase
83+
@end
84+
85+
@implementation RCTTurboModuleStringConversionTests {
86+
std::unique_ptr<jsi::Runtime> _runtime;
87+
}
88+
89+
- (void)setUp
90+
{
91+
[super setUp];
92+
_runtime = facebook::hermes::makeHermesRuntime();
93+
}
94+
95+
- (void)tearDown
96+
{
97+
_runtime.reset();
98+
[super tearDown];
99+
}
100+
101+
- (void)assertConvertsToSameCharacters:(NSString *)string
102+
{
103+
jsi::Value value = convertObjCObjectToJSIValue(*_runtime, string);
104+
XCTAssertTrue(value.isString(), @"Expected a JS string for \"%@\"", string);
105+
XCTAssertTrue(
106+
value.asString(*_runtime).utf16(*_runtime) == utf16FromNSString(string),
107+
@"Expected the JS string to have the same characters as \"%@\"",
108+
string);
109+
}
110+
111+
- (void)testASCIIStringWithASCIIPointer
112+
{
113+
NSString *string = stringFromUTF8Data(@"com.facebook.react.uiapp");
114+
XCTAssertTrue(hasASCIIPointer(string), @"Expected the string to expose its ASCII characters");
115+
[self assertConvertsToSameCharacters:string];
116+
[self assertConvertsToSameCharacters:@"constant"];
117+
}
118+
119+
- (void)testTaggedPointerString
120+
{
121+
// Short strings like this one are tagged pointers, which have no character buffer.
122+
NSString *string = stringWithCharacters({u'i', u'd'});
123+
XCTAssertFalse(hasASCIIPointer(string), @"Expected the string to have no ASCII pointer");
124+
XCTAssertFalse(hasUTF16Pointer(string), @"Expected the string to have no UTF-16 pointer");
125+
[self assertConvertsToSameCharacters:string];
126+
}
127+
128+
- (void)testNonASCIIString
129+
{
130+
NSString *string = stringFromUTF8Data(@"Zażółć gęślą jaźń");
131+
XCTAssertTrue(hasUTF16Pointer(string), @"Expected the string to expose its UTF-16 characters");
132+
[self assertConvertsToSameCharacters:string];
133+
[self assertConvertsToSameCharacters:stringFromUTF8Data(@"日本語のテキスト")];
134+
}
135+
136+
- (void)testStringWithSurrogatePairs
137+
{
138+
[self assertConvertsToSameCharacters:stringFromUTF8Data(@"Rocket 🚀 and family 👨‍👩‍👧")];
139+
}
140+
141+
- (void)testEmptyString
142+
{
143+
[self assertConvertsToSameCharacters:@""];
144+
}
145+
146+
- (void)testLargeString
147+
{
148+
NSMutableString *string = [NSMutableString new];
149+
for (int i = 0; i < 20000; i++) {
150+
[string appendFormat:@"{\"id\":%d,\"name\":\"Zażółć %d 🚀\"},", i, i];
151+
}
152+
[self assertConvertsToSameCharacters:stringFromUTF8Data(string)];
153+
}
154+
155+
- (void)testStringSubclass
156+
{
157+
NSString *string =
158+
[[RCTTurboModuleStringConversionTestsString alloc] initWithCharacters:{u'a', u'ż', 0xD83D, 0xDE80}];
159+
XCTAssertFalse(hasASCIIPointer(string), @"Expected the string to have no ASCII pointer");
160+
XCTAssertFalse(hasUTF16Pointer(string), @"Expected the string to have no UTF-16 pointer");
161+
[self assertConvertsToSameCharacters:string];
162+
}
163+
164+
- (void)testStringWithNullCharacterIsNotTruncated
165+
{
166+
NSString *ascii = [[NSString alloc] initWithBytes:"aaaaaaaaaaaaaaaaaaaa\0b" length:22 encoding:NSUTF8StringEncoding];
167+
XCTAssertTrue(hasASCIIPointer(ascii), @"Expected the string to expose its ASCII characters");
168+
[self assertConvertsToSameCharacters:ascii];
169+
[self assertConvertsToSameCharacters:stringWithCharacters({u'a', 0, u'b'})];
170+
[self assertConvertsToSameCharacters:stringWithCharacters({u'ż', 0, u'b'})];
171+
}
172+
173+
- (void)testStringWithLoneSurrogateIsKept
174+
{
175+
NSString *string = stringWithCharacters({u'a', 0xD800, u'b'});
176+
XCTAssertTrue(hasUTF16Pointer(string), @"Expected the string to expose its UTF-16 characters");
177+
[self assertConvertsToSameCharacters:string];
178+
[self assertConvertsToSameCharacters:stringWithCharacters({u'a', 0xDC00})];
179+
}
180+
181+
- (void)testStringSubclassWithLoneSurrogateIsKept
182+
{
183+
NSString *string = [[RCTTurboModuleStringConversionTestsString alloc] initWithCharacters:{u'a', 0xD800, u'b'}];
184+
XCTAssertFalse(hasUTF16Pointer(string), @"Expected the string to have no UTF-16 pointer");
185+
[self assertConvertsToSameCharacters:string];
186+
}
187+
188+
@end

0 commit comments

Comments
 (0)