Reputation: 139
I'm experiencing some odd behaviour concatenating strings containing Arabic characters, While I cannot read Arabic text, it does look quite obvious that something strange is happening as it appears to re - arranging the order of the text/ characters when the uni code isn't being used.
var concat =
"مركز صيانة الإحساء (مركز صيانة ، قطع غيار)" + "\u202a" + "مركز الصيانة"
Concat provides me with the correct concatenation when logged, giving me -
مركز صيانة الإحساء (مركز صيانة ، قطع غيار)مركز الصيانة
but without the unicode appears as -
مركز صيانة الإحساء (مركز صيانة ، قطع غيار) مركز الصيانة
which is incorrect
I understand Arabic is read from RTL and that has a role to play in the behaviour. From what I've read regarding this, my understanding is that issues like this occur when concatenating LTR and RTL languages into one string, and not concatenating RTL with another RTL. I was wondering if someone would be able to help me understand this? Thanks
Upvotes: 0
Views: 1665
Reputation: 16675
but without the unicode appears as -
مركز صيانة الإحساء (مركز صيانة ، قطع غيار) مركز الصيانة
which is incorrect
(As an Arabic and Hebrew speaking person): The string above is the correct output for your concatenation. Because Arabic is a RTL language, concatenating the string:
مركز صيانة الإحساء (مركز صيانة ، قطع غيار)
with
مركز الصيانة
Should return:
مركز صيانة الإحساء (مركز صيانة ، قطع غيار) مركز الصيانة
Don't let the brackets throw you off. Any IDE will show the last bracket on the right side of the string, but it's actually on the left side (at the end) of the string. The best way to examine a combination of RTL strings with special characters like brackets, periods, commas ect. is to paste the string to a Notepad, and click the right side ctrl + shift to change the text direction to right to left:
Upvotes: 1