Why UILabel behaves differently in iOS 14 and iOS 13, when NSString contains RTL language

For example, label.text = @"5.6k متابعين".

in iOS 13, the "5.6k" will be rendered at the left. I can understand it based on Unicode Bidirectional Algorithm.

But in iOS 14, the "5.6k" will be rendered at the right, I can't understand(I guess RTL language has a higher priority than LTRs, but not sure)

Who can explain it? Thanks!

Answered by justin2048 in 666902022
Alright, I found that all is caused by localizedStringWithFormat:.
in iOS 14, it would add U+2068 and U+2069 (unicode FSI) around "5.6k". So the text's direction was decided by the Arabic part. This is a new feature of localizedStringWithFormat: in iOS 14.
I tested in simulator iOS 14.4.
"5.6k" is rendered at the left

I tested on 12.4 simulator.
Same result.

Could you give more details ?
Do you run on device ? Did you test on simulator ?
@Claude31 
Firstly, at the Localizable.strings file add the following line:
"%@_fans" = "%@ متابعين";

And then create string like this:
NSString *num = @"5.6k";
NSString *str = [NSString localizedStringWithFormat:NSLocalizedString(@"%@_fans", nil), num];
label.text = str;

It will show different result between iOS 13 and iOS 14, both simulator and device
Accepted Answer
Alright, I found that all is caused by localizedStringWithFormat:.
in iOS 14, it would add U+2068 and U+2069 (unicode FSI) around "5.6k". So the text's direction was decided by the Arabic part. This is a new feature of localizedStringWithFormat: in iOS 14.
Why UILabel behaves differently in iOS 14 and iOS 13, when NSString contains RTL language
 
 
Q