callmekatootie
callmekatootie

Reputation: 11228

Error while exporting csv data in Firefox

I have a huge set of data that is exported as csv in my web application.

I will simplify it for easy understanding. Let me say that I have the following text:

text,value
Sample text,This is the #1 site for answers

Its been formatted and ready for exporting as csv. Before that, I encode it using encodeURI() and then I assign it to the href attribute of an anchor tag as:

data:text/csv;utf-8,<the encoded string goes here>

The issue is that only when the string contains a #, only in Firefox, the entire CSV file is not downloaded. Only upto the row previous to the row containing # is downloaded. This happens only in firefox.

If I replace the # with an alphabet, everything is fine. The hash character upsets the download - only in firefox.

Upvotes: 3

Views: 806

Answers (1)

paa
paa

Reputation: 5054

Use the encodeURIComponent function.

Upvotes: 1

Related Questions