r15122 by jghali - #9119 (can't import utf-8 encoded text file) : convert unicode importing to be like the text importer
scribus-commit
scribus-commit at lists.scribus.net
Thu May 27 15:40:24 CEST 2010
Revision: 15122
Author: jghali
Date: 2010-05-27T13:37:15.852953Z
Commit message: #9119 (can't import utf-8 encoded text file) : convert unicode importing to be like the text importer
Changeset:
M /branches/Version135/Scribus/scribus/plugins/gettext/csvim/csvim.h
M /branches/Version135/Scribus/scribus/plugins/gettext/csvim/csvim.cpp
Diffs:
Index: scribus/plugins/gettext/csvim/csvim.cpp
===================================================================
--- scribus/plugins/gettext/csvim/csvim.cpp (revision 15121)
+++ scribus/plugins/gettext/csvim/csvim.cpp (revision 15122)
@@ -6,6 +6,7 @@
*/
#include "csvim.h"
#include "scribusstructs.h"
+#include "util.h"
QString FileFormatName()
{
@@ -89,19 +90,9 @@
void CsvIm::loadFile()
{
QString text = "";
- QFile f(filename);
- QFileInfo fi(f);
- if (!fi.exists())
- return;
- QByteArray bb(f.size(), ' ');
- if (f.open(QIODevice::ReadOnly))
- {
- f.read(bb.data(), f.size());
- f.close();
- for (int posi = 0; posi < bb.size(); ++posi)
- text += QChar(bb[posi]);
- }
- text = toUnicode(text);
+ QByteArray rawText;
+ if (loadRawText(filename, rawText))
+ text = toUnicode(rawText);
QStringList lines = text.split("\n", QString::SkipEmptyParts);
uint i;
if (hasHeader)
@@ -215,15 +206,15 @@
}
}
-QString CsvIm::toUnicode(const QString& text)
+QString CsvIm::toUnicode(const QByteArray& rawText)
{
QTextCodec *codec;
if (encoding.isEmpty())
codec = QTextCodec::codecForLocale();
else
codec = QTextCodec::codecForName(encoding.toLocal8Bit());
- QString dec = codec->toUnicode(text.toLocal8Bit());
- return dec;
+ QString unistr = codec->toUnicode(rawText);
+ return unistr;
}
CsvIm::~CsvIm()
Index: scribus/plugins/gettext/csvim/csvim.h
===================================================================
--- scribus/plugins/gettext/csvim/csvim.h (revision 15121)
+++ scribus/plugins/gettext/csvim/csvim.h (revision 15122)
@@ -50,7 +50,7 @@
gtParagraphStyle *pstyleHeader;
void loadFile();
void parseLine(const QString& line, bool isHeader);
- QString toUnicode(const QString& text);
+ QString toUnicode(const QByteArray& rawText);
void setupPStyles();
void setupTabulators();
};
More information about the scribus-commit
mailing list