summaryrefslogtreecommitdiff
path: root/src/CSV.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/CSV.hs')
-rw-r--r--src/CSV.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/CSV.hs b/src/CSV.hs
index dd56961..b4850b4 100644
--- a/src/CSV.hs
+++ b/src/CSV.hs
@@ -55,7 +55,10 @@ specialChars s = (separator s):(quote s):(escape s):[]
unParseRecord :: Settings -> [String] -> String
unParseRecord settings record =
let escFunc c = if (c == escape settings || c == quote settings) then (escape settings):c:[] else c:[]
- escapeField s = ((quote settings) : (concatMap escFunc s)) ++ ((quote settings):[])
+ escapeField s =
+ if ((escape settings) `elem` s || (quote settings) `elem` s || (separator settings) `elem` s)
+ then ((quote settings) : (concatMap escFunc s)) ++ ((quote settings):[])
+ else s
in List.intercalate [separator settings] (map escapeField record)