Beispiel #1
0
	QString stripControlBytes(const QString & szData)
	{
		QString szRet;

		int i = 0;
		int iBegin = 0;
		unsigned char c1;
		unsigned char c2;
		while(i < szData.length())
		{
			switch(szData[i].unicode())
			{
				case KviControlCodes::Underline:
				case KviControlCodes::Bold:
				case KviControlCodes::Reset:
				case KviControlCodes::Reverse:
				case KviControlCodes::CryptEscape:
				case KviControlCodes::CTCP:
					if(i != iBegin)
						szRet += szData.mid(iBegin,i - iBegin);
					i++;
					iBegin = i;
				break;
				case KviControlCodes::Color:
					if(i != iBegin)
						szRet += szData.mid(iBegin,i - iBegin);
					i++;
					i = getUnicodeColorBytes(szData,i,&c1,&c2);
					iBegin = i;
				break;
				case KviControlCodes::Icon:
					if(i != iBegin)
						szRet += szData.mid(iBegin,i - iBegin);
					i++;
					/*
					* These lines will strip out the first word following the icon escape character
					while(i < l)
					{
						if(szData[i].unicode() == ' ')
							break;
						else i++;
					}
					*/
					iBegin = i;
				break;
				default:
					i++;
				break;
			}
		}
		if(i != iBegin)
			szRet += szData.mid(iBegin,i - iBegin);
		return szRet;
	}
	QString stripControlBytes(const QString & szData)
	{
		QString szRet;

		int i = 0;
		int iBegin = 0;
		unsigned char c1;
		unsigned char c2;
		while(i < szData.length())
		{
			switch(szData[i].unicode())
			{
				case KviControlCodes::Underline:
				case KviControlCodes::Bold:
				case KviControlCodes::Italic:
				case KviControlCodes::Reset:
				case KviControlCodes::Reverse:
				case KviControlCodes::CryptEscape:
				case KviControlCodes::CTCP:
				case KviControlCodes::Icon:
					if(i != iBegin)
						szRet += szData.mid(iBegin, i - iBegin);
					i++;
					iBegin = i;
					break;
				case KviControlCodes::Color:
					if(i != iBegin)
						szRet += szData.mid(iBegin, i - iBegin);
					i++;
					i = getUnicodeColorBytes(szData, i, &c1, &c2);
					iBegin = i;
					break;
				default:
					i++;
					break;
			}
		}
		if(i != iBegin)
			szRet += szData.mid(iBegin, i - iBegin);
		return szRet;
	}