Evgeni Atanasov Evgeni Atanasov - 10 months ago 57
Javascript Question

Arabic RTL characters break CSV file

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 :

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:


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

Answer Source

Ok, I fixed this problem. The string contains \r\n which seemed like space character and were very hard to identify.