Closed joe-meyer closed 9 years ago
Can you link to a test case showing the issue and confirm what version of Buttons you are using please.
Ya so sorry about that completely missed the contributing guidelines.
Edit: Buttons version 1.0.3
in https://github.com/DataTables/Buttons/blob/master/js/buttons.html5.js#L311 changing the \\
to "
seems to resolve this specifc issue. I'm far from a csv guru when it comes to the encoding rules though, not sure what other use cases that might break;
s += boundary ?
boundary + a[i].replace( boundary, '"'+boundary ) + boundary :
a[i];
Update: not a complete fix... ran into an even more obscure use case: http://jsfiddle.net/50x1m4bt/
Thanks for the JS Fiddle.
From your demo, in the CSV output I get:
"Part Description"
"BUMPER 16\",STL,CR,TOW"
That looks correct in its escaping to me. What would you have expected it to be?
Apparently further research seems to indicate that there isn't really a "standard" for escaping. But Microsoft Excel uses a "
for escaping, not a \
. I also stumbled across a rfc memo, which apparently is a recommended implementation as opposed to a standard. See https://tools.ietf.org/html/rfc4180
In that RFC they outline escaping which aligns better with using Excel.
Haha... So it goes. I'll look into making the escape character an customisable parameter and read through the RFC before making any changes to Buttons - thanks for the research and link!
@DataTables the escape character becoming a customization parameter seems ideal. That's how PHP seems to deal with it with their fputcsv()
function.
Finally done. I've change the default to be "
for the escape character, based on the information in the RFC. However, it is easy to change it as needed now using the escapeChar
option.
Thanks for bringing this up.
Should have checked the issue tracker first! Just diagnosed this! FYI to late visitors, this affects 1.0.3, and is patched in 1.1.0+
I have the following data value in one of my table cells:
BUMPER-16",STL,CUST,TOW
When using the html5 csv export I end up with several cells which look like| BUMPER 16\ | STL | CR | TOW" |