parent
81507a3b27
commit
d7f38d2a01
@ -0,0 +1,29 @@ |
||||
#include <QDebug> |
||||
#include "UBTextTools.h" |
||||
|
||||
QString UBTextTools::cleanHtmlCData(const QString &_html){ |
||||
|
||||
QString clean = ""; |
||||
|
||||
|
||||
for(int i = 0; i < _html.length(); i+=1){ |
||||
if(_html.at(i) != '\0') |
||||
clean.append(_html.at(i)); |
||||
} |
||||
return clean; |
||||
} |
||||
|
||||
QString UBTextTools::cleanHtml(const QString& _html){ |
||||
const QString START_TAG = "<!doctype"; |
||||
const QString END_TAG = "</html"; |
||||
|
||||
QString cleanSource = ""; |
||||
QString simplifiedHtml = _html; |
||||
|
||||
int start = simplifiedHtml.toLower().indexOf(START_TAG); |
||||
int end = simplifiedHtml.toLower().indexOf(END_TAG) + END_TAG.size(); |
||||
|
||||
cleanSource = simplifiedHtml.mid(start, end); |
||||
|
||||
return cleanSource; |
||||
} |
@ -0,0 +1,15 @@ |
||||
#ifndef UBTEXTTOOLS_H |
||||
#define UBTEXTTOOLS_H |
||||
|
||||
#include <QString> |
||||
|
||||
class UBTextTools{ |
||||
public: |
||||
UBTextTools(){} |
||||
virtual ~UBTextTools(){} |
||||
|
||||
static QString cleanHtmlCData(const QString& _html); |
||||
static QString cleanHtml(const QString& _html); |
||||
}; |
||||
|
||||
#endif // UBTEXTTOOLS_H
|
Loading…
Reference in new issue