从右到左的语言支架颠倒了 [英] Right To Left Language Bracket Reversed

查看:45
本文介绍了从右到左的语言支架颠倒了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中使用StringBuilder附加一些文本,这些文本可以是英语(从左到右)或阿拉伯语(从右到左)

I am using a StringBuilder in C# to append some text, which can be English (left to right) or Arabic (right to left)

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

如果text ="A",则输出为(A)A"

If text = "A", then output is "(A) A"

但是如果text =بتث",则输出为(بتب)بتث"

But if text = "بتث", then output is "(بتث) بتث"

有什么想法吗?

推荐答案

当要求渲染从右到左的文本(阿拉伯语或希伯来语)时,这是Windows文本渲染引擎中的一个众所周知的缺陷.这是一个很难解决的问题,当语言中没有合适的替代词时,人们常常会退回到西方单词和标点符号.例如,品牌和公司名称.渲染器尝试通过查看代码点来猜测正确的渲染顺序,而拉丁字符集中的字符显然必须从左到右进行渲染.

This is a well-known flaw in the Windows text rendering engine when asked to render Right-To-Left text, Arabic or Hebrew. It has a difficult problem to solve, people often fall back to Western words and punctuation when there is no good alternative word available in the language. Brand and company names for example. The renderer tries to guess at the proper render order by looking at the code points, with characters in the Latin character set clearly having to be rendered left-to-right.

但是它在标点符号时摸索不清,最明显的是方括号.您必须对此很明确,以便它知道要做什么,您必须在C#代码中使用Unicode从右到左标记, U + 200F \ u200f .相反,如果您知道需要LTR渲染,请使用从左到右标记, U + 200E .

But it fumbles at punctuation, with brackets being the most visible. You have to be explicit about it so it knows what to do, you must use the Unicode Right-to-left mark, U+200F or \u200f in C# code. Conversely, use the Left-to-right mark if you know you need LTR rendering, U+200E.

这篇关于从右到左的语言支架颠倒了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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