Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SanitizeUTF8(QString &r, bool allowSpaces)
- {
- for(int i = 0; i < r.size();)
- {
- const QChar c = r.at(i);
- const bool removeSpace = !allowSpaces && c.isSpace();
- if(
- removeSpace || !c.isPrint() || c.isMark() ||
- c.category() == QChar::Other_Control ||
- c.category() == QChar::Other_Format ||
- c.category() == QChar::Other_NotAssigned || c.category() == QChar::Other_PrivateUse ||
- c.category() == QChar::Symbol_Other ||
- // 'Arabic Presentation Forms-A'
- (c.unicode() >= 64336 && c.unicode() <= 65023) ||
- // 'Arabic Presentation Forms-B'
- (c.unicode() >= 65136 && c.unicode() <= 65279) ||
- // Replacement Chars / End of the line
- c.unicode() >= 65532 ||
- // Jamo Fillers
- c.unicode() == 4447 || c.unicode() == 4448 || c.unicode() == 12644
- ///
- /// NOTES - QChar::Letter_Other is in use by chinese people
- ///
- #if QT_VERSION < 0x050000
- // This code definitely worked in 4.6 and was seen to break in 5.1, hasn't been tried since
- || c.category() == QChar::NoCategory
- #endif
- )
- {
- r.replace(i, 1, "");
- }
- else
- {
- ++i;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement