aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2017-11-30 02:40:07 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2017-11-30 02:40:07 +0000
commit50f72ab6a11e25dbf9431c06adb3f7f16315befe (patch)
tree8a03904422826399eba812606a6f5cf2e5401f85 /libsylph
parentd85e720cb558df0206b93b6d956116b7d2754f44 (diff)
addressbook csv export: fixed double-quote escape and added header line.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3587 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/utils.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index a76d0a55..aabce066 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -1730,6 +1730,12 @@ gchar **strsplit_csv(const gchar *str, gchar delim, gint max_tokens)
return str_array;
}
+/* Concatenate multiple strings into a CSV (TSV) record.
+ * If delimiter characters or double-quotes appear in the string,
+ it is enclosed by double quotes.
+ * Double quote characters are escaped by another double quote.
+ * Strings must not include line breaks in this implementation.
+ */
gchar *strconcat_csv(gchar delim, const gchar *field1, ...)
{
va_list args;
@@ -1749,7 +1755,7 @@ gchar *strconcat_csv(gchar delim, const gchar *field1, ...)
if (count > 0)
g_string_append_c(csv, delim);
- if (delim != '\t' && strchr(s, delim) != NULL)
+ if (strchr(s, delim) != NULL || strchr(s, '"') != NULL)
add_quote = TRUE;
if (add_quote)
g_string_append_c(csv, '"');