如何防止希伯来语和阿拉伯语的自动从右到左文本方向? [英] How to prevent automatic right-to-left text direction for Hebrew and Arabic?

查看:441
本文介绍了如何防止希伯来语和阿拉伯语的自动从右到左文本方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TextView中,当文本以希伯来字母开头时,整个文本以RTL模式显示.

问题是在我的情况下,只有第一个单词是希伯来语,而整个句子是英语,所以不是

 דני went to school

用户看到的

                                                  went to school דני

(当用英语阅读时,第一个单词在句子的结尾)

如何防止这种情况发生,并迫使文本从左侧开始?

解决方案

Unicode字符本质上是LTR或RTL.在大多数情况下,整个文本均以第一个字符为准.希伯来语字符是RTL.

请参见 http://en.wikipedia.org/wiki/Bi-directional_text

您的文本以RTL字符开头,因此被视为RTL.您可以使用left-to-right mark"\u200E"强制将其视为LTR.

以此特殊字符开头的文本将告诉布局系统整个文本的显式方向.不过,由于字符是明确的RTL,因此仍将RTL节视为这样.

例如,数字并不是很强的指标,因此不会影响放置它们的部分的方向.因此,不同方向的部分之间的数字可能会成为问题,并且可能需要明确指示. /p>

In a TextView, when a text starts with a Hebrew letter, the entire text is shown in RTL mode.

The problem is that in my case only the first word is in Hebrew, while the entire sentence is in English, so instead of

 דני went to school

the user sees

                                                  went to school דני

(the first word is in the end of the sentence, when reading in English)

How can I prevent this from happening and force the text to start from the left?

解决方案

Unicode characters are intrisectly LTR or RTL. In most situations, the whole text takes its orientation from the first character. Hebrew character are RTL.

See http://en.wikipedia.org/wiki/Bi-directional_text

Your text starts with a RTL character, and is therefore considered RTL. You can force it to be seen as LTR by using the left-to-right mark, "\u200E".

Starting your text with this special character will tell the layout system the explicit orientation of the whole text. RTL sections will still be considered as such, though, because the characters are explicitly RTL.

Numbers, for example, are not a strong indicator, and therefore don't affect the direction of the section they are placed in. Therefore, numbers between section of different direction can be a problem, and may need explicit indication.

这篇关于如何防止希伯来语和阿拉伯语的自动从右到左文本方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆