Commit 313bd10d0d5ef1281accdb9990d933875dcdee6e

Authored by Scott Klum
1 parent a82be108

Added support for carriage return when reading files

openbr/core/qtutils.cpp
@@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
24 #include <QProcess> 24 #include <QProcess>
25 #include <QProcessEnvironment> 25 #include <QProcessEnvironment>
26 #include <QRegExp> 26 #include <QRegExp>
  27 +#include <QRegularExpression>
27 #include <QStack> 28 #include <QStack>
28 #include <QUrl> 29 #include <QUrl>
29 #include <openbr/openbr_plugin.h> 30 #include <openbr/openbr_plugin.h>
@@ -79,7 +80,7 @@ void readFile(const QString &amp;file, QStringList &amp;lines) @@ -79,7 +80,7 @@ void readFile(const QString &amp;file, QStringList &amp;lines)
79 { 80 {
80 QByteArray data; 81 QByteArray data;
81 readFile(file, data); 82 readFile(file, data);
82 - lines = QString(data).split('\n', QString::SkipEmptyParts); 83 + lines = QString(data).split(QRegularExpression("[\n|\r\n|\r]"), QString::SkipEmptyParts);
83 for (int i=0; i<lines.size(); i++) 84 for (int i=0; i<lines.size(); i++)
84 lines[i] = lines[i].simplified(); 85 lines[i] = lines[i].simplified();
85 } 86 }
openbr/plugins/format.cpp
@@ -151,7 +151,7 @@ class csvFormat : public Format @@ -151,7 +151,7 @@ class csvFormat : public Format
151 { 151 {
152 QFile f(file.name); 152 QFile f(file.name);
153 f.open(QFile::ReadOnly); 153 f.open(QFile::ReadOnly);
154 - QStringList lines(QString(f.readAll()).split('\n')); 154 + QStringList lines(QString(f.readAll()).split(QRegularExpression("[\n|\r\n|\r]"), QString::SkipEmptyParts));
155 f.close(); 155 f.close();
156 156
157 bool isUChar = true; 157 bool isUChar = true;