TextArea LTR / RTL [英] TextArea LTR/RTL
问题描述
我有一个简单的html textarea,主体具有RTL风格,所以textarea从body继承风格。所以问题在后面。
问题:
我必须使用$(#myTextArea)将以下文本显示到文本区域中。从ajax结果到这里)。
文本如下,
پاکستانکاکارواتباکستانکالاقلرقبہ796096-0-0مربعکلومیٹرزہے。
和其他文字相似,只需几行。现在乌尔都语文本中的数字实际上是796096-0-0,但它是反向显示的。整个案文中有几个这样的数字。请告诉我一种方法,我可以将数字显示为LTR,其余文本显示为RTL。
谢谢。
// str =我的文章796096-0-0مربعکلومیٹرزہے。;
str = str.replace(/([ - 0-9] +)/ g,\\\ $ 1\\\);
您必须将此字符串放置在CSS属性 direction
设置为 rtl
,或者您必须添加\\\
字符,否则这些部分以相反的顺序出现(但方向正确)。
这些是Unicode方向控制字符:
- U + 202A:从左到右嵌入
- U + 202C:弹出方向格式化嵌入)
- U + 202E:从右到左覆盖
以此作为参考: http://www.iamcal.com/understanding-bidirectional-text /
I have a simple html textarea, the body has RTL style and so textarea inherits the style from body. So the problem is following.
Problem: I have to display the following text into text area using $("#myTextArea").val("text from an ajax result comes here").
The text is following,
پاکستان کا کل رقبہ 796096-0-0 مربع کلو میٹرز ہے۔
and the rest of the text is similar and takes several lines. Now the number in the Urdu text is actually 796096-0-0 but it is displayed reverse. There are several such numbers throughout the text. Please tell me a way that I could display the numbers as LTR and the rest of the text as RTL as usual.
Thanks.
// str = "پاکستان کا کل رقبہ 796096-0-0 مربع کلو میٹرز ہے۔";
str = str.replace(/([-0-9]+)/g, "\u202a$1\u202c");
You'll have to place this string in a container that has the CSS attribute direction
set to rtl
, or you'll have to add a "\u202E"
character to the beginning, otherwise the sections appeared in reverse order (but in the correct direction).
These are Unicode direction control characters:
- U+202A: left-to-right embedding
- U+202C: pop-directional-formatting (basically end of embedding)
- U+202E: right-to-left override
I've been using this as a reference: http://www.iamcal.com/understanding-bidirectional-text/
这篇关于TextArea LTR / RTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!