gnucash maint: Bug 796833 - Excel csv Format misprocessed

Geert Janssens gjanssens at code.gnucash.org
Tue Sep 4 05:28:49 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/f6d873dc (commit)
	from  https://github.com/Gnucash/gnucash/commit/e47b460a (commit)



commit f6d873dc2722a339f284bb84ffa2159b9087e781
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Tue Sep 4 11:28:16 2018 +0200

    Bug 796833 - Excel csv Format misprocessed
    
    Convert all line ending styles to the one expected by the C++ standard
    library before starting to parse a csv file.

diff --git a/gnucash/import-export/csv-imp/gnc-tokenizer.cpp b/gnucash/import-export/csv-imp/gnc-tokenizer.cpp
index 0a15fa0..2f54db6 100644
--- a/gnucash/import-export/csv-imp/gnc-tokenizer.cpp
+++ b/gnucash/import-export/csv-imp/gnc-tokenizer.cpp
@@ -12,6 +12,7 @@
 #include <memory>
 
 #include <boost/locale.hpp>
+#include <boost/algorithm/string.hpp>
 
 extern "C" {
 #include <go-glib-extras.h>
@@ -79,6 +80,11 @@ GncTokenizer::encoding(const std::string& encoding)
 {
     m_enc_str = encoding;
     m_utf8_contents = boost::locale::conv::to_utf<char>(m_raw_contents, m_enc_str);
+
+    // While we are converting here, let's also normalize line-endings to "\n"
+    // That's what STL expects by default
+    boost::replace_all (m_utf8_contents, "\r\n", "\n");
+    boost::replace_all (m_utf8_contents, "\r", "\n");
 }
 
 const std::string&



Summary of changes:
 gnucash/import-export/csv-imp/gnc-tokenizer.cpp | 6 ++++++
 1 file changed, 6 insertions(+)



More information about the gnucash-changes mailing list