Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

incorrect right to left concatenation english and Arabic

Tags:

c#

I'm trying to concatenate an English string with Arabic string

string followUpFormula = "FIF";
string renewAbbreviation =  "ع.ت" ;
string abbreviation = followUpFormula +"-"+ renewAbbreviation;
var result = 10 + "/" + abbreviation + "/" + 2016;

the result is 10/FIF-ع.ت/2016 but i want to display them like this: 10/FIF-ع.ت/
2016

how can I do that? thanks

like image 314
Mohammad Qurashi Avatar asked Aug 25 '16 13:08

Mohammad Qurashi


1 Answers

Couple of additions to your code

string followUpFormula = "FIF";
string renewAbbreviation =  "ع.ت" ;
string abbreviation = followUpFormula +"-"+ renewAbbreviation;
var lefttoright = ((Char)0x200E).ToString();
var result = 10 + "/" + abbreviation + lefttoright + "/" + 2016;

Char 0x200E is a special character that tells the following text to read left to right see here for more information on the character.

Char 0x200F switches to a right to left format.

like image 84
Takarii Avatar answered Sep 30 '22 23:09

Takarii