From 78a3f0eda630c31595b49a5432093c12a3651494 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Sat, 21 Mar 2020 17:14:56 +0100
Subject: [PATCH] replacing all newline and tab in rawInput with spaces

---
 common/include/utf8string.hpp      | 1 +
 common/src/utf8string.cpp          | 5 +++++
 reading_machine/src/BaseConfig.cpp | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/common/include/utf8string.hpp b/common/include/utf8string.hpp
index 42fe5d4..2a7400e 100644
--- a/common/include/utf8string.hpp
+++ b/common/include/utf8string.hpp
@@ -29,6 +29,7 @@ class utf8string : public std::vector<utf8char>
   utf8string & operator=(const std::string & other);
   utf8string & operator=(const char * const other);
   bool operator==(const std::string & other);
+  void replace(utf8char from, utf8char to);
 };
 
 };
diff --git a/common/src/utf8string.cpp b/common/src/utf8string.cpp
index d430197..42755db 100644
--- a/common/src/utf8string.cpp
+++ b/common/src/utf8string.cpp
@@ -70,3 +70,8 @@ bool util::utf8string::operator==(const std::string & other)
   return true;
 }
 
+void util::utf8string::replace(utf8char from, utf8char to)
+{
+  std::replace(begin(), end(), from, to);
+}
+
diff --git a/reading_machine/src/BaseConfig.cpp b/reading_machine/src/BaseConfig.cpp
index 696d76c..f3a1ed9 100644
--- a/reading_machine/src/BaseConfig.cpp
+++ b/reading_machine/src/BaseConfig.cpp
@@ -49,6 +49,8 @@ void BaseConfig::readRawInput(std::string_view rawFilename)
   std::fclose(file);
 
   rawInputUtf8 = util::splitAsUtf8(rawInputTemp);
+  rawInputUtf8.replace(util::utf8char("\n"), util::utf8char(" "));
+  rawInputUtf8.replace(util::utf8char("\t"), util::utf8char(" "));
 }
 
 void BaseConfig::readTSVInput(std::string_view tsvFilename)
-- 
GitLab