javascript Data URI charset when saving
I am using something like this in a utf-8 page:

    var data = "a \t b \t c \r\n d \t e \tf";
    window.location.href = "data:text/csv;charset=utf-8," + encodeURIComponent(data);

to force the browser to download the text and save it. I works fine except that when I open the file in excel it does not open correctly (it neither reads the separator nor the arabic characters).. I need to "import data" to specify that the file is UTF-8, when I do this it works correctly... When I open the file in notepad and resave it in unicode... it works correctly. Is there a way to force it to save in unicode from the start? or make the csv file open correctly in excel.

I tried to change it to "charset=utf-16" but it didn't work.

Any help is appreciated.
Thanks
javascript Data URI charset when saving
===

I am using something like this in a utf-8 page:

    var data = "a \t b \t c \r\n d \t e \tf";
    window.location.href = "data:text/csv;charset=utf-8," + encodeURIComponent(data);

to force the browser to download the text and save it. I works fine except that when I open the file in excel it does not open correctly (it neither reads the separator nor the arabic characters).. I need to "import data" to specify that the file is UTF-8, when I do this it works correctly... When I open the file in notepad and resave it in unicode... it works correctly. Is there a way to force it to save in unicode from the start? or make the csv file open correctly in excel.

I tried to change it to "charset=utf-16" but it didn't work.

Any help is appreciated.
Thanks