Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate DateTime string with Arabic String

Tags:

c#

asp.net

I'm trying to concatenate an Arabic string with a leading DateTime, I have tried in various way but the DateTime always ends up at the end of the string

var arabicText = "Jim قام بإعادة تعيين هذه المهمة إلى John";
var dateTime = DateTime.Now;

System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("ar-AE");

string test1 = arabicText + " :" + dateTime.ToString();
string test2 = arabicText + " :" + dateTime.ToString(ci);

So when this is displayed it should show

Jim قام بإعادة تعيين هذه المهمة إلى John :02/10/2012

but I always seem to end up with

02/10/2012: Jim قام بإعادة تعيين هذه المهمة إلى John

Any ideas would be apprecicated

like image 448
user1714591 Avatar asked Oct 02 '12 14:10

user1714591


2 Answers

You can use with this code

var strArabic = "Jim قام بإعادة تعيين هذه المهمة إلى John";
var strEnglish = dateTime.ToString() ; 
var LRM = ((char)0x200E).ToString();  // This is a LRM
var result = strArabic  + LRM +  strEnglish ; 
like image 189
Aghilas Yakoub Avatar answered Sep 28 '22 07:09

Aghilas Yakoub


Try using string.Format:

string test1 = string.Format("{0}:  {1}", arabicText, dateTime.ToString());

That should produce the result you're looking for.

like image 24
PiousVenom Avatar answered Sep 28 '22 08:09

PiousVenom