Fix crash when calling substring() on a string containing emoji. (#23609)

Summary:
Fixes #23459. It is not legal to write the character array of a std::string, and can result in undefined behavior.

[General] [Fixed] - Crash when substring intersects with emoji
Pull Request resolved: https://github.com/facebook/react-native/pull/23609

Differential Revision: D14198159

Pulled By: mdvacca

fbshipit-source-id: 71060b1b99ddab89793c98c09f99ec9974479e62
This commit is contained in:
ericlewis
2019-03-01 00:53:00 -08:00
committed by Facebook Github Bot
parent e903d8059a
commit 58c3a4c078
4 changed files with 12 additions and 8 deletions

View File

@@ -615,11 +615,13 @@ class TextExample extends React.Component<{}> {
Works with other text styles
</Text>
</RNTesterBlock>
<RNTesterBlock title="Substring Emoji (should only see 'test')">
<Text>{'test🙃'.substring(0, 5)}</Text>
</RNTesterBlock>
</RNTesterPage>
);
}
}
const styles = StyleSheet.create({
backgroundColorText: {
left: 5,