From f6d873dc2722a339f284bb84ffa2159b9087e781 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 4 Sep 2018 11:28:16 +0200 Subject: [PATCH] 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. --- gnucash/import-export/csv-imp/gnc-tokenizer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gnucash/import-export/csv-imp/gnc-tokenizer.cpp b/gnucash/import-export/csv-imp/gnc-tokenizer.cpp index 0a15fa042b..2f54db6aae 100644 --- a/gnucash/import-export/csv-imp/gnc-tokenizer.cpp +++ b/gnucash/import-export/csv-imp/gnc-tokenizer.cpp @@ -12,6 +12,7 @@ #include #include +#include extern "C" { #include @@ -79,6 +80,11 @@ GncTokenizer::encoding(const std::string& encoding) { m_enc_str = encoding; m_utf8_contents = boost::locale::conv::to_utf(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&