string.Format问题,从左到右的语言与从右到左的语言连接在一起 [英] string.Format problem in concatenating left-to-right languages with right-to-left languages

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

问题描述

波斯语是从右到左的语言.我想向用户显示一条消息,表明已成功保存某些内容.但是,该事物(实体)的名称有时用英语,有时用波斯语.因此,对于英语单词,我应该将一些波斯语单词与占位符组合在一起:

Persian is a right-to-left language. I want to show a message to the user that something was saved successfully. However, the name of that thing (entity) is sometimes in English, and sometimes in Persian. Thus I should combine some Persian words with placeholders for English words as follow:

string.Format("مطلب {0} با موفقیت ذخیره شد", contentTitle);

现在,如果我们假设contentTitle为How to solve your problem,则连接的字符串将为:

Now, if we suppose that contentTitle is How to solve your problem, the concatenated string would be:

مطلب How to solve your problem با موفقیت ذخیره شد.

这不是我想要的.理想的结果应该是:

This is not what I want to get. The desirable result should be:

.با موفقیت ذخیره شد How to solve your problem مطلب

我该怎么办?似乎string.Format方法在将从左到右的语言与从右到左的语言连接在一起方面存在问题.我要实现的目标与 CSS写作中的direction: rtl;非常相似.

What should I do? It seems that string.Format method has problem in concatenating left-to-right languages with right-to-left languages. What I want to achieve is very similar to direction: rtl; in CSS Writing.

推荐答案

字符串类对RTL一无所知,Windows拥有自己的规则来处理混合内容"(即一个字符串中的rtl和ltr) ...

the string class doesn't know anything about RTL and Windows has its own rules to deal with "mixed content" (that is rtl and ltr in one string)...

您可以尝试使用LROLRE等.在这些字符串中使用Unicode提示"以获得所需的结果-请参见

you can experiment with LRO, LRE etc. Unicode "hints" in those string to achieve desired result - see table at http://en.wikipedia.org/wiki/Bi-directional_text

这篇关于string.Format问题,从左到右的语言与从右到左的语言连接在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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