diff --git a/src/import-export/csv-exp/csv-transactions-export.c b/src/import-export/csv-exp/csv-transactions-export.c index 4be3c849f8..b09d7855e7 100644 --- a/src/import-export/csv-exp/csv-transactions-export.c +++ b/src/import-export/csv-exp/csv-transactions-export.c @@ -256,7 +256,11 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh ) g_free (part1); /* From Number Only */ +#ifdef G_OS_WIN32 part1 = g_strconcat (part2, "", mid_sep, "", mid_sep, "", end_sep, "\n", NULL); +#else + part1 = g_strconcat (part2, "", mid_sep, "", mid_sep, "", end_sep, "\r\n", NULL); +#endif g_free (part2); /* Write to file */ @@ -346,9 +350,17 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh ) split_amount = xaccPrintAmount (xaccSplitGetSharePrice (t_split), gnc_split_amount_print_info (t_split, FALSE)); str_temp = csv_txn_test_field_string (info, split_amount); if (xaccSplitGetAccount (t_split) == acc) +#ifdef G_OS_WIN32 part2 = g_strconcat (part1, str_temp, mid_sep, end_sep, "\n", NULL); - else +#else + part2 = g_strconcat (part1, str_temp, mid_sep, end_sep, "\r\n", NULL); +#endif + else +#ifdef G_OS_WIN32 part2 = g_strconcat (part1, mid_sep, str_temp, end_sep, "\n", NULL); +#else + part2 = g_strconcat (part1, mid_sep, str_temp, end_sep, "\r\n", NULL); +#endif g_free (str_temp); g_free (part1); @@ -415,7 +427,11 @@ void csv_transactions_export (CsvExportInfo *info) _("To With Sym"), mid_sep, _("From With Sym"), mid_sep, _("To Num."), mid_sep, _("From Num."), mid_sep, _("To Rate/Price"), mid_sep, _("From Rate/Price"), +#ifdef G_OS_WIN32 end_sep, "\n", NULL); +#else + end_sep, "\r\n", NULL); +#endif DEBUG("Header String: %s", header); /* Write header line */ diff --git a/src/import-export/csv-exp/csv-tree-export.c b/src/import-export/csv-exp/csv-tree-export.c index f07b49cfed..da4ab74465 100644 --- a/src/import-export/csv-exp/csv-tree-export.c +++ b/src/import-export/csv-exp/csv-tree-export.c @@ -144,12 +144,19 @@ void csv_tree_export (CsvExportInfo *info) } /* Header string, 'eol = end of line marker' */ - header = g_strconcat ( end_sep, _("type"), mid_sep, _("full_name"), mid_sep, - _("name"), mid_sep, _("code"), mid_sep, - _("description"), mid_sep, _("color"), mid_sep, _("notes"), mid_sep, - _("commoditym"), mid_sep, _("commodityn"), mid_sep, - _("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), mid_sep, - _("#eol"), end_sep, "\n", NULL); +#ifdef G_OS_WIN32 + header = g_strconcat (end_sep, _("type"), mid_sep, _("full_name"), mid_sep, _("name"), mid_sep, + _("code"), mid_sep, _("description"), mid_sep, _("color"), mid_sep, + _("notes"), mid_sep, _("commoditym"), mid_sep, _("commodityn"), mid_sep, + _("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), mid_sep, _("#eol"), + end_sep, "\n", NULL); +#else + header = g_strconcat (end_sep, _("type"), mid_sep, _("full_name"), mid_sep, _("name"), mid_sep, + _("code"), mid_sep, _("description"), mid_sep, _("color"), mid_sep, + _("notes"), mid_sep, _("commoditym"), mid_sep, _("commodityn"), mid_sep, + _("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), mid_sep, _("#eol"), + end_sep, "\r\n", NULL); +#endif DEBUG("Header String: %s", header); /* Write header line */ @@ -229,7 +236,11 @@ void csv_tree_export (CsvExportInfo *info) g_free (part2); /* Place Holder / end of line marker */ currentSel = xaccAccountGetPlaceholder (acc) ? "T" : "F" ; +#ifdef G_OS_WIN32 part2 = g_strconcat (part1, currentSel, mid_sep, _("#eol"), end_sep, "\n", NULL); +#else + part2 = g_strconcat (part1, currentSel, mid_sep, _("#eol"), end_sep, "\r\n", NULL); +#endif g_free (part1); DEBUG("Account String: %s", part2); diff --git a/src/import-export/csv-imp/csv-account-import.c b/src/import-export/csv-imp/csv-account-import.c index 68e73a8408..58e62d4f92 100644 --- a/src/import-export/csv-imp/csv-account-import.c +++ b/src/import-export/csv-imp/csv-account-import.c @@ -119,8 +119,13 @@ csv_import_read_file (const gchar *filename, const gchar *parser_regexp, } /* Setup the two different line endings */ +#ifdef G_OS_WIN32 end1 = g_strconcat (_("#eol"),"\"\n", NULL); end2 = g_strconcat (_("#eol"),"\n", NULL); +#else + end1 = g_strconcat (_("#eol"),"\"\r\n", NULL); + end2 = g_strconcat (_("#eol"),"\r\n", NULL); +#endif // start the import #define buffer_size 1000 @@ -154,11 +159,14 @@ csv_import_read_file (const gchar *filename, const gchar *parser_regexp, break; // eof } - // now strip the '\n' from the end of the line + // now strip the '\r\n' from the end of the line l = strlen (currentline); if ((l > 0) && (currentline[l - 1] == '\n')) currentline[l - 1] = 0; + if ((l > 0) && (currentline[l - 2] == '\r')) + currentline[l - 2] = 0; + // convert line from locale into utf8 line_utf8 = g_locale_to_utf8 (currentline, -1, NULL, NULL, NULL);