Concat Rtl String With Ltr String In Javascript
I'm facing trouble in concatenating Arabic string with English string but their order is being messed! I tried + operator and str1.concat(..) but nothing works for me. var a = 'eng
Solution 1:
The characters your are looking for are \u202A
, \u202B
and \u202C
function wrap_dir(dir, str) {
if (dir === 'rtl') return'\u202B' + str + '\u202C';
return'\u202A' + str + '\u202C';
}
wrap_dir('ltr', a) + wrap_dir('ltr', '\\') + wrap_dir('rtl', b) + wrap_dir('ltr', '\\') + wrap_dir('ltr', c);
// "english\أ.ب-000082-13\000004-ر خ-2014.xml"
Not sure why c
wanted to be LTR, maybe because it ends .xml
?
Post a Comment for "Concat Rtl String With Ltr String In Javascript"