Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHCSVParser/CHCSVParser/CHCSVParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ typedef NS_ENUM(NSInteger, CHCSVErrorCode) {

@interface CHCSVWriter : NSObject

/**
* Defines that writer should always surround fields with double quote sign
*/
@property (nonatomic, assign) BOOL alwaysDoubleQuote;

/**
* Initializes a @c CHCSVWriter to write to the provided file path. Assumes @c NSUTF8Encoding and the comma delimiter
*
Expand Down
2 changes: 1 addition & 1 deletion CHCSVParser/CHCSVParser/CHCSVParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ - (void)writeField:(id)field {

NSString *string = field ? [field description] : @"";

if ([string rangeOfCharacterFromSet:_illegalCharacters].location != NSNotFound) {
if (self.alwaysDoubleQuote || [string rangeOfCharacterFromSet:_illegalCharacters].location != NSNotFound) {
// replace double quotes with double double quotes
string = [string stringByReplacingOccurrencesOfString:@"\"" withString:@"\"\""];
// surround in double quotes
Expand Down