Commit 313bd10d0d5ef1281accdb9990d933875dcdee6e
1 parent
a82be108
Added support for carriage return when reading files
Showing
2 changed files
with
3 additions
and
2 deletions
openbr/core/qtutils.cpp
| ... | ... | @@ -24,6 +24,7 @@ |
| 24 | 24 | #include <QProcess> |
| 25 | 25 | #include <QProcessEnvironment> |
| 26 | 26 | #include <QRegExp> |
| 27 | +#include <QRegularExpression> | |
| 27 | 28 | #include <QStack> |
| 28 | 29 | #include <QUrl> |
| 29 | 30 | #include <openbr/openbr_plugin.h> |
| ... | ... | @@ -79,7 +80,7 @@ void readFile(const QString &file, QStringList &lines) |
| 79 | 80 | { |
| 80 | 81 | QByteArray data; |
| 81 | 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 | 84 | for (int i=0; i<lines.size(); i++) |
| 84 | 85 | lines[i] = lines[i].simplified(); |
| 85 | 86 | } | ... | ... |
openbr/plugins/format.cpp
| ... | ... | @@ -151,7 +151,7 @@ class csvFormat : public Format |
| 151 | 151 | { |
| 152 | 152 | QFile f(file.name); |
| 153 | 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 | 155 | f.close(); |
| 156 | 156 | |
| 157 | 157 | bool isUChar = true; | ... | ... |