From aea4d46d121e30285014bf70aa277b140e0fd16d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Fri, 22 Jan 2010 00:28:38 +0000 Subject: - When exporting CSVs containing linebreaks, no longer escape those linebreaks if they are within a quoted cell, improving compatibility with other applications (notably Excel) --- Source/TableDump.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/TableDump.m b/Source/TableDump.m index e555786b..15a8c344 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -2128,20 +2128,18 @@ options:NSLiteralSearch range:NSMakeRange(0, [csvCellString length])]; } - - // Escape occurrences of the line end character - [csvCellString replaceOccurrencesOfString:lineEndString - withString:escapedLineEndString - options:NSLiteralSearch - range:NSMakeRange(0, [csvCellString length])]; // If the string isn't quoted or otherwise enclosed, escape occurrences of the - // field separators + // field separators and line end character if ( quoteFieldSeparators || csvCellIsNumeric ) { [csvCellString replaceOccurrencesOfString:fieldSeparatorString withString:escapedFieldSeparatorString options:NSLiteralSearch range:NSMakeRange(0, [csvCellString length])]; + [csvCellString replaceOccurrencesOfString:lineEndString + withString:escapedLineEndString + options:NSLiteralSearch + range:NSMakeRange(0, [csvCellString length])]; } // Write out the cell data by appending strings - this is significantly faster than stringWithFormat. -- cgit v1.2.3