从左到右马克不在Swift工作

时间:2023-01-06 11:39:51

I'm trying to use LRM in order to make a string properly displays in arabic. My string is as follows:

我正在尝试使用LRM以使字符串正确显示在阿拉伯语中。我的字符串如下:

Percentage is: 32.12%

百分比是:32.12%

However on arabic it displayed as:

然而在阿拉伯语上它显示为:

%32.12 :نسبة ط

%32.12:نسبةط

So far so good. On objective-c I've used in the past following markup to fix this problem:

到现在为止还挺好。在objective-c上我过去使用过以后的标记来解决这个问题:

[NSString stringWithFormat:@"\u200E %@", value]

But when I try it on Swift it just didn't move the percent:

但是当我在Swift上尝试它时,它只是没有移动百分比:

"\u{200E}\(value)"

Am I using unicode characters wrong in Swift or I made mistake somewhere else?

我在Swift中使用unicode字符错误还是​​在其他地方犯了错误?

1 个解决方案

#1


6  

The below should be a comment on the question, really, but I need the formatting...

下面应该是对问题的评论,真的,但我需要格式化......

I do this in a Playground (Xcode 7 beta 4)

我在Playground(Xcode 7 beta 4)中这样做

let value = "32.12%"
print("نسبة ط:\u{200E}\(value)")

And it prints

它打印出来

32.12% :نسبة ط

Is that what you want?

那是你要的吗?

Also

let value = "\u{200E}32.12%"
print("نسبة ط:\(value)")

works the same. This is in the Playground. Are you using an older version of Xcode perhaps?

工作原理相同。这是在游乐场。您使用的是旧版Xcode吗?

#1


6  

The below should be a comment on the question, really, but I need the formatting...

下面应该是对问题的评论,真的,但我需要格式化......

I do this in a Playground (Xcode 7 beta 4)

我在Playground(Xcode 7 beta 4)中这样做

let value = "32.12%"
print("نسبة ط:\u{200E}\(value)")

And it prints

它打印出来

32.12% :نسبة ط

Is that what you want?

那是你要的吗?

Also

let value = "\u{200E}32.12%"
print("نسبة ط:\(value)")

works the same. This is in the Playground. Are you using an older version of Xcode perhaps?

工作原理相同。这是在游乐场。您使用的是旧版Xcode吗?