Right to left language bracket

I use StringBuilder in C # to add some text, which can be English (left to right) or Arabic (right to left)

stringBuilder.Append("(");
stringBuilder.Append(text);
stringBuilder.Append(") ");
stringBuilder.Append(text);

If text = "A", then the output will be "(A) A"

But if text = "بتث", then the output will be "(بتث) بتث"

Any ideas?

+5
source share
3 answers

Windows, , . , , , . , . , , .

, . , , , " ", U+200F \u200f #. , , , LTR, U+200E.

+7

AppendFormat Append:

stringBuilder.AppendFormat("({0}) {0}", text)

, - text - , , LTR/RTL. .

0

I had a similar problem, and I was able to solve it by creating a function that checks every Char in Unicode. If it is from the FE page, I add 202C after it, as shown below. Without it, he will use RTL and LTF for what I wanted.

string us = string.Format("\uFE9E\u202C\uFE98\u202C\uFEB8\u202C\uFEC6\u202C\uFEEB\u202C\u0020\u0660\u0662\u0664\u0668 Aa1");
0
source

All Articles