asafdav / ng-csv

Simple directive that turns arrays and objects into downloadable CSV files
MIT License
573 stars 215 forks source link

tab separated value as field separator #93

Closed elderbas closed 9 years ago

elderbas commented 9 years ago

If you only pass in Get TSV, angular escapes the "\t" and doesnt give you the tab character. This correctly lets you use \t as a valid separator.

asafdav commented 9 years ago

Hi, thanks for this pull request. I think this could be generalize to handle every escaped '\' characters. In addition please provide some test cases

elderbas commented 9 years ago

Hmm... you're right. Which do you want from https://msdn.microsoft.com/en-us/library/ie/2yfce773%28v=vs.94%29.aspx ?

If you want "all" of them I was thinking of adding... \t, \b, \v, \f, \r, \", and \'.

Since the rest of them don't really seem intuitive to want to use.

The reason I ask "which" ones is because I think the only easy solution is to use a hash table like this var specialChars = { "\t": "\t", "\b": "\b", "\v": "\v", "\f": "\f", "\r": "\r", '\"': '\"', "\'": "\'" };

or something similar.

asafdav commented 9 years ago

What about '\' ?

elderbas commented 9 years ago

If they input \ into field-sep="\" then Angular will escape it to a normal backslash, which would be what they probably wanted to begin with, so I don't think it needs that.

asafdav commented 9 years ago

Yes you're right, cool.

asafdav commented 9 years ago

Closing in favor of #94