Javascript string section issue in arabic / persian strings

I am trying to break two Persian characters using javascript string markup, but it does not split properly.

var test = '"حسن روحانی"،"حسن+روحانی"';
var tmpkeywords =  test.split(',');
console.log(tmpkeywords);

the separation result should be as follows: ["حسن روحانی" "," حسن + روحانی ""]

but instead it goes like ["حسن روحانی", "حسن + روحانی" ↵ "]. It works well in English characters or numbers.

My fiddle: https://jsfiddle.net/tueo3sfa/1/

+4
source share
1 answer

"حسن روحانی"،"حسن+روحانی" "," (U + 002C COMMA), "،" (U + 060C ARABIC COMMA): .

, , "،"

var test = '"حسن روحانی"،"حسن+روحانی"';
var tmpkeywords =  test.split(',');
console.log(tmpkeywords);

, , , ( http://www.fileformat.info/info/unicode/char/search.htm?q=comma&han=Y&preview=entity) , , Unicode (, , . http://inimino.org/~inimino/blog/javascript_cset ).

+1
source

Source: https://habr.com/ru/post/1688586/


All Articles