开发者

Unexpected RightToLeft String concatenation

开发者 https://www.devze.com 2023-03-30 22:02 出处:网络
Lets say I have a DataRow with a number of columns like this, //header firstnameEnglish , FirstNameArabic, LastnameEnglish , LastNameArabic,

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', 'جميل','||开发者_JAVA百科',  '11 ELHaram street','11 شارع الهرم'

which is wrong.

I want to know why is this happing and how to solve this

Thanks


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?)

0

精彩评论

暂无评论...
验证码 换一张
取 消