{
QMap<uint,QString> webchars;
webchars.
insert(8226,
QString(" "));
/* • */ QdocXhtml *convert = new QdocXhtml();
QString html
= convert
->Format
(stream
);
/* tidy try to clean */ for (int i = 0; i < html.size(); ++i) {
const uint asciiPos = (uint)sign.unicode();
bool replaceUnis = false;
if ((asciiPos >= 240) && (asciiPos <= 255)) {
replaceUnis = true;
} else if ((asciiPos >= 224) && (asciiPos <= 239)) {
replaceUnis = true;
} else if ((asciiPos >= 192) && (asciiPos <= 223)) {
replaceUnis = true;
} else if ( asciiPos >7999 ) {
replaceUnis = true;
}
if (replaceUnis) {
/////////QString charU = QString("%1").arg(asciiPos);
///////QByteArray preU = QByteArray();
//////const int prepender = qBound(1,5 - charU.size(),5);
///////preU.fill('0',prepender);
///////const QString UnicodeChar = QString("&#%2%1").arg(charU).arg(preU.data());
webchars.insert(asciiPos,UnicodeChar);
}
}
QMapIterator<uint,QString> i(webchars);
while (i.hasNext()) {
i.next();
html
= html.
replace(QChar(i.
key()),i.
value());
}
return html;
}
static inline QString HTML2Filter( QString stream )
{
QMap<uint,QString> webchars;
webchars.insert(8226,QString(" ")); /* • */
webchars.insert(194,QString(" "));
webchars.insert(13,QString(""));
webchars.insert(10,QString(""));
QdocXhtml *convert = new QdocXhtml();
QString html = convert->Format(stream); /* tidy try to clean */
for (int i = 0; i < html.size(); ++i) {
QChar sign = html.at(i);
const uint asciiPos = (uint)sign.unicode();
bool replaceUnis = false;
if ((asciiPos >= 240) && (asciiPos <= 255)) {
replaceUnis = true;
} else if ((asciiPos >= 224) && (asciiPos <= 239)) {
replaceUnis = true;
} else if ((asciiPos >= 192) && (asciiPos <= 223)) {
replaceUnis = true;
} else if ( asciiPos >7999 ) {
replaceUnis = true;
}
if (replaceUnis) {
/////////QString charU = QString("%1").arg(asciiPos);
///////QByteArray preU = QByteArray();
//////const int prepender = qBound(1,5 - charU.size(),5);
///////preU.fill('0',prepender);
///////const QString UnicodeChar = QString("&#%2%1").arg(charU).arg(preU.data());
const QString UnicodeChar = QString("&#%1").arg(asciiPos);
webchars.insert(asciiPos,UnicodeChar);
}
}
QMapIterator<uint,QString> i(webchars);
while (i.hasNext()) {
i.next();
html = html.replace(QChar(i.key()),i.value());
}
return html;
}
To copy to clipboard, switch view to plain text mode
Bookmarks