forked from qt-creator/qt-creator
Utils: Remove superseded readFileUTF8 overload
Superseded by the version added in commit c1225ea.
Change-Id: I7cd8186b613b31e235d045f28e2b0f339784b59e
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -271,39 +271,6 @@ TextFileFormat::ReadResult
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFileFormat::ReadResult TextFileFormat::readFileUTF8(const QString &fileName,
|
|
||||||
QByteArray *plainText, QString *errorString)
|
|
||||||
{
|
|
||||||
QByteArray data;
|
|
||||||
try {
|
|
||||||
Utils::FileReader reader;
|
|
||||||
if (!reader.fetch(fileName, errorString))
|
|
||||||
return TextFileFormat::ReadIOError;
|
|
||||||
data = reader.data();
|
|
||||||
} catch (const std::bad_alloc &) {
|
|
||||||
*errorString = QCoreApplication::translate("Utils::TextFileFormat", "Out of memory.");
|
|
||||||
return TextFileFormat::ReadMemoryAllocationError;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFileFormat format = TextFileFormat::detect(data);
|
|
||||||
if (!format.codec)
|
|
||||||
format.codec = QTextCodec::codecForLocale();
|
|
||||||
if (format.codec->name() == "UTF-8") {
|
|
||||||
if (format.hasUtf8Bom)
|
|
||||||
data.remove(0, 3);
|
|
||||||
*plainText = data;
|
|
||||||
return TextFileFormat::ReadSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString target;
|
|
||||||
if (!format.decode(data, &target)) {
|
|
||||||
*errorString = QCoreApplication::translate("Utils::TextFileFormat", "An encoding error was encountered.");
|
|
||||||
return TextFileFormat::ReadEncodingError;
|
|
||||||
}
|
|
||||||
*plainText = target.toUtf8();
|
|
||||||
return TextFileFormat::ReadSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFileFormat::ReadResult TextFileFormat::readFileUTF8(const QString &fileName,
|
TextFileFormat::ReadResult TextFileFormat::readFileUTF8(const QString &fileName,
|
||||||
const QTextCodec *defaultCodec,
|
const QTextCodec *defaultCodec,
|
||||||
QByteArray *plainText, QString *errorString)
|
QByteArray *plainText, QString *errorString)
|
||||||
|
|||||||
@@ -76,8 +76,6 @@ public:
|
|||||||
static ReadResult readFile(const QString &fileName, const QTextCodec *defaultCodec,
|
static ReadResult readFile(const QString &fileName, const QTextCodec *defaultCodec,
|
||||||
QString *plainText, TextFileFormat *format, QString *errorString,
|
QString *plainText, TextFileFormat *format, QString *errorString,
|
||||||
QByteArray *decodingErrorSample = 0);
|
QByteArray *decodingErrorSample = 0);
|
||||||
static ReadResult readFileUTF8(const QString &fileName, QByteArray *plainText,
|
|
||||||
QString *errorString); // TODO: Remove this version.
|
|
||||||
static ReadResult readFileUTF8(const QString &fileName, const QTextCodec *defaultCodec,
|
static ReadResult readFileUTF8(const QString &fileName, const QTextCodec *defaultCodec,
|
||||||
QByteArray *plainText, QString *errorString);
|
QByteArray *plainText, QString *errorString);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user