Changeset View
Changeset View
Standalone View
Standalone View
man/man2html.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | |||||
125 | 125 | | |||
126 | #include <QByteArray> | 126 | #include <QByteArray> | ||
127 | #include <QDateTime> | 127 | #include <QDateTime> | ||
128 | #include <QMap> | 128 | #include <QMap> | ||
129 | #include <QStack> | 129 | #include <QStack> | ||
130 | #include <QString> | 130 | #include <QString> | ||
131 | #include <QTextCodec> | 131 | #include <QTextCodec> | ||
132 | #include <QDebug> | 132 | #include <QDebug> | ||
133 | #include <QRegularExpression> | ||||
133 | 134 | | |||
134 | #ifdef SIMPLE_MAN2HTML | 135 | #ifdef SIMPLE_MAN2HTML | ||
135 | # include <stdlib.h> | 136 | # include <stdlib.h> | ||
136 | # include <iostream> | 137 | # include <iostream> | ||
137 | # include <dirent.h> | 138 | # include <dirent.h> | ||
138 | # include <sys/stat.h> | 139 | # include <sys/stat.h> | ||
139 | # include <QFile> | 140 | # include <QFile> | ||
140 | # include <QFileInfo> | 141 | # include <QFileInfo> | ||
▲ Show 20 Lines • Show All 6021 Lines • ▼ Show 20 Line(s) | 6162 | { | |||
6162 | // as we do not know in which encoding the man source is, try to automatically | 6163 | // as we do not know in which encoding the man source is, try to automatically | ||
6163 | // detect it and always return it as UTF-8 | 6164 | // detect it and always return it as UTF-8 | ||
6164 | 6165 | | |||
6165 | QByteArray encoding; | 6166 | QByteArray encoding; | ||
6166 | 6167 | | |||
6167 | // some pages contain "coding:" information. See "man manconv" | 6168 | // some pages contain "coding:" information. See "man manconv" | ||
6168 | // (but I find pages which do not exactly obey the format described in manconv, e.g. | 6169 | // (but I find pages which do not exactly obey the format described in manconv, e.g. | ||
6169 | // the control char is either "." or "'") | 6170 | // the control char is either "." or "'") | ||
6170 | // Therefore use a QRegExp | 6171 | // Therefore use a QRegularExpression | ||
6171 | QRegExp regex("[\\.']\\\\\"[^$]*coding:\\s*(\\S*)\\s", Qt::CaseInsensitive); | 6172 | const QRegularExpression regex("[\\.']\\\\\"[^$]*coding:\\s*(\\S*)\\s", QRegularExpression::CaseInsensitiveOption); | ||
6172 | if ( regex.indexIn(QLatin1String(input)) == 0 ) | 6173 | QRegularExpressionMatch rmatch; | ||
6174 | if (QString::fromLatin1(input).indexOf(regex, 0, &rmatch) == 0) | ||||
6173 | { | 6175 | { | ||
6174 | encoding = regex.cap(1).toLatin1(); | 6176 | encoding = rmatch.captured(1).toLatin1(); | ||
6175 | 6177 | | |||
6176 | qCDebug(KIO_MAN_LOG) << "found embedded encoding" << encoding; | 6178 | qCDebug(KIO_MAN_LOG) << "found embedded encoding" << encoding; | ||
6177 | } | 6179 | } | ||
6178 | else | 6180 | else | ||
6179 | { | 6181 | { | ||
6180 | // check according to the dirName the man page is in | 6182 | // check according to the dirName the man page is in | ||
6181 | 6183 | | |||
6182 | // if the dirName contains a ".", the encoding follows, e.g. "de.UTF-8" | 6184 | // if the dirName contains a ".", the encoding follows, e.g. "de.UTF-8" | ||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |