Xcode LTR和RTL文本混合在数据库中

时间:2022-09-01 08:58:27

I had the same problem when I tried implementing the same scenario in a Android studio app here Android studio question and answer

当我尝试在Android工作室应用程序中实现相同的场景时,我遇到了同样的问题Android studio问题和答案

Now I have the same issue in Xcode, I'm using data from a database and displaying it in a textview, whenever a list view item starts with LTR text then the rest of the line displays correct even if there is RTL word in the middel of it. But whenever a item starts with RTL text, it throws the whole item to RTL and not only the RTL word.

现在我在Xcode中遇到同样的问题,我正在使用数据库中的数据并在文本视图中显示它,每当列表视图项以LTR文本开头时,即使在middel中有RTL单词,该行的其余部分也会显示正确它但是每当一个项目以RTL文本开头时,它都会将整个项目抛出到RTL而不仅仅是RTL单词。

Is there any way I can force the view to always stay LTR even if it starts with a RTL word, like the answer marked in the link above?

是否有任何方法可以强制视图始终保持LTR,即使它以RTL字开头,如上面链接中标记的答案?

Bidi codes just gets displayed, as if it doesn't know what to do with the codes. Examples:

Bidi代码只会显示,就好像它不知道如何处理代码一样。例子:

I want to display the following:

我想显示以下内容:

‘אנא אנא - Ek is, was, sal wees Wie Ek is, was, sal wees.”

'אנאאנא - Ek是,是的,我们是Wie Ek,是,sal wees。

But it gets displayed as:

但它显示为:

”.Ek is, was, sal wees Wie Ek is, was, sal wees - אנא אנא‘

“.Ek是,是,我们是Wie Ek,是,sal wees - אנאאנא'

When the hebrew text is between other normal text its fine like:

当希伯来文本介于其他普通文本之间时,其罚款如下:

‘He says אנא אנא - I am, was, shall be Who I am, was, shall be.”

“他说的是 - 我,是,我将是谁,是,将来。”

1 个解决方案

#1


1  

If someone comes across the question with the same issue I got the following answer. Add this to your viewcontroller after displaying your string from the database :

如果有人遇到同样的问题我得到了以下答案。从数据库中显示字符串后,将其添加到viewcontroller:

[_content appendString:@" \u200E"] ;

[_content appendString:@“\ u200E”];

#1


1  

If someone comes across the question with the same issue I got the following answer. Add this to your viewcontroller after displaying your string from the database :

如果有人遇到同样的问题我得到了以下答案。从数据库中显示字符串后,将其添加到viewcontroller:

[_content appendString:@" \u200E"] ;

[_content appendString:@“\ u200E”];