forked from qt-creator/qt-creator
3rdparty/syntax-highlighting: Adapt HtmlHighlighter to Qt6 codec use
Change-Id: Ifb784b02b01f4cfe89879eae7e2866b694f45581 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -61,13 +61,21 @@ void HtmlHighlighter::setOutputFile(const QString &fileName)
|
||||
return;
|
||||
}
|
||||
d->out.reset(new QTextStream(d->file.get()));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
d->out->setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
d->out->setCodec("UTF-8");
|
||||
#endif
|
||||
}
|
||||
|
||||
void HtmlHighlighter::setOutputFile(FILE *fileHandle)
|
||||
{
|
||||
d->out.reset(new QTextStream(fileHandle, QIODevice::WriteOnly));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
d->out->setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
d->out->setCodec("UTF-8");
|
||||
#endif
|
||||
}
|
||||
|
||||
void HtmlHighlighter::highlightFile(const QString &fileName, const QString &title)
|
||||
@@ -110,7 +118,11 @@ void HtmlHighlighter::highlightData(QIODevice *dev, const QString &title)
|
||||
*d->out << "><pre>\n";
|
||||
|
||||
QTextStream in(dev);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
in.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
in.setCodec("UTF-8");
|
||||
#endif
|
||||
while (!in.atEnd()) {
|
||||
d->currentLine = in.readLine();
|
||||
state = highlightLine(d->currentLine, state);
|
||||
|
||||
Reference in New Issue
Block a user