Arabic RTL characters break CSV file

时间:2016-10-20 13:05:52

标签: javascript python regex csv arabic

I am trying to generate CSV file with javascript.

Everything is superb with the file, but since the data I am exporting in the CSV may contain arabic characters some of the rows appear as if they have \n(new line)

This is my input data:

حاجى مالك نورزى (Hajji Malik Noorzai; Hajji Malak Noorzai; Haji Malek Noorzai);Haji Maluk;Haji Aminullah;Allah Muhammad

This is the output in the CSV file, here is not visiable :

MALIK NOORZAI;
                    Haji Malek Noorzai);Allah Muhammad;Haji Aminullah;Haji Maluk;Hajji Malak Noorzai;حاجى مالك نورزى (Hajji Malik Noorzai

Can anybody help me how to sort this out?

I have idea to check if my string contains arabic characters with regex, and then wrap it with something like the answers in this thread: Concat RTL string with LTR string in javascript

I have tried with this regex:

/[\u0600-\u06FF]/g

which in my opinion leaves the first character حاجى مالك نورزى unmatched(by first I mean the leftest)

1 个答案:

答案 0 :(得分:0)

好的,我解决了这个问题。 该字符串包含\ r \ n,它看起来像空格字符,很难识别。