[SR-14301] Open-source String.localizedStringWithFormat(_:_:…)
does not insert Unicode Isolates
#4219
Labels
String.localizedStringWithFormat(_:_:…)
does not insert Unicode Isolates
#4219
Environment
Added the tests in the description to the Foundation test suite and ran them using
Additional Detail from JIRA
md5: 0cb11fd67f4fd37a5cd358ffcdc0697f
Issue Description:
According to WWDC 2016 Session 232 (“What's New in International User Interfaces”), iOS 10 and later support Unicode Isolates for bidirectional text. Also according to that session, `NSString.init(format:locale:arguments🙂` should automatically wrap embedded text in Unicode Isolates (U+2068 FIRST STRONG ISOLATE and U+2069 POP DIRECTIONAL ISOLATE).
This is necessary for text dynamically-embedded at the start of the string because the embedded text could be either LTR or RTL. From my understanding, the text display system follows the Unicode Bidirectional Algorithm rule P2, which sets the overall direction of the text to the direction of the first strong character. Without Unicode Isolates, this is problematic because the embedded text could be LTR while the rest of the text is RTL (or vice versa). Wrapping the embedded text in Unicode Isolates solves this problem by telling the algorithm to skip the embedded text when evaluating rule P2.
(Note that iOS had a bug (FB7330789) where Unicode Isolates were not automatically inserted for embedded LTR text. That bug is now fixed in iOS 14.)
The open-source Foundation should match the behavior of Darwin Foundation but in this case, it doesn’t. The following tests should pass but they currently fail:
The text was updated successfully, but these errors were encountered: