Concatenating unicode (LtR and RtL) strings?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have two string variables (x and y).  One contains Arabic script, the other contains numbers (1, 2, 3, etc).  For example:

<div style="margin-left:40px   // arabic
            char aleph = u0627;
            char ra = u0631;
            char dal = u062F;
            char wao = u0648;
            string x = aleph.ToString() + ra.ToString() + dal.ToString() + wao.ToString();

<div style="margin-left:40px   // numbers
            char one = u0031;
            char two = u0032;
            char three = u0033;
            char four = u0034;
            string y = one.ToString() + two.ToString() + three.ToString() + four.ToString();

<div style="margin-left:40px   Debug.Writeline(x + y);

When I concatenate x + y and write it out to the debug output window, it looks like this:


<div style="margin-left:40px اردو1234


I also have a third string variable (z) that holds English text and it is defined like this:

<div style="margin-left:40px   // english text
            char a = u0061;
            char b = u0062;
            char c = u0063;
            char d = u0064;
            string z = a.ToString() + b.ToString() + c.ToString() + d.ToString();

<div style="margin-left:40px   Debug.Writeline(x + z);

When I concatenate x + z and write it out to the debug output window, it looks like this:


<div style="margin-left:40px اردوabcd


I understand that Arabic is a Right-to-left language so it makes sense to me that the arabic portion of the string is being displayed "backwards".  What Im not clear about is why the numbers are being written out on the left hand side of the arabic (x + y) while the English letters are being written out on the right hand side of the arabic (x + z).  Can anyone shed some light on this behavior?  Thanks very much in advance!!

View the full article
 
Back
Top