意外的 RightToLeft 字符串连接
假设我有一个 DataRow
,其中包含许多像这样的列,
//header
firstnameEnglish , FirstNameArabic, LastnameEnglish , LastNameArabic,
project, addressEnglish, addressِArabic
//data'hatem', 'حاتم', 'gamil','جميل','||',
'11 el haram street ','11 םן'
我想获取字符串中的行数据,我可以将其导出到文本文件。
我在 DataRow
列上执行 for
循环,如下所示,
string data = String.Empty;
for(int i=0; i < datarow.columns.count<0; i++)
datastr += datarow[i] + " | ";
我的问题是,data
中的字符串以错误的方式连接。经过调试,我发现连接进展顺利,直到将 addressEnglish
连接到 data
为止。此时,data
已包含从连接列到阿拉伯列的值。
输出是,
'hatem', 'حاتم', 'gamil', 'جميل','||', '11 ELHaram street','11 شارع الهرم'
这是错误的。
我想知道为什么会发生这种情况以及如何解决这个问题
谢谢
Lets say I have a DataRow
with a number of columns like this,
//header
firstnameEnglish , FirstNameArabic, LastnameEnglish , LastNameArabic,
project, addressEnglish, addressِArabic
//data'hatem', 'حاتم', 'gamil','جميل','||',
'11 el haram street ','11 الهرم'
I want to get the row data in a string where I can export it to a text file.
I do a for
loop on the DataRow
columns something like this,
string data = String.Empty;
for(int i=0; i < datarow.columns.count<0; i++)
datastr += datarow[i] + " | ";
My problem is, the string in data
is concatenated the wrong way. After debugging, I found that the concatenation is going well until concatenating the addressEnglish
to the data
. At this point data
already contains the values from the concatenated columns up to and including the arabic columns.
The output is,
'hatem', 'حاتم', 'gamil', 'جميل','||', '11 ELHaram street','11 شارع الهرم'
which is wrong.
I want to know why is this happing and how to solve this
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定这不是您用来在屏幕上显示结果的程序的问题吗?由于阿拉伯语是从右到左的,因此支持 Unicode 的程序通常使用启发式方法来决定阿拉伯语短语周围的标点符号的数量应与其一起从右到左呈现。
逐个字符转储可以更轻松地确定确实存在需要解决的问题。
(相反,您确定输入 csv 中的标点符号以正确的顺序存储吗?)
Are you sure it's not a matter of the program you're using to display you results on the screen? Since Arabic is right-to-left, Unicode-aware programs often use heuristics to decide how much of the punctuation surrounding the Arabic phrase it should render right-to-left together with it.
A character-by-character dump would make it easier to be sure that there is actually a problem to solve.
(Conversely, are you sure that the punctuation in the input csv is stored in the right order?)