Beispiel #1
0
bool StringFindReplacer::Search(const wchar_t* input, int startOffset, const wchar_t* find_what, size_t flags, int &pos, int &matchLen, int& posInChars, int& matchLenInChars)
{
    // adjust startOffset due to it is in bytes but should be in chars
    int iSO = startOffset;
    while (iSO > 0 && (int)UTF8Length(input, iSO) > startOffset) iSO--;
    startOffset = iSO;

    bool bResult = false;
    if ( flags & wxSD_WILDCARD ) {
        bResult = DoWildcardSearch(input, startOffset, find_what, flags, posInChars, matchLenInChars);
        flags |= wxSD_REGULAREXPRESSION;
        
    } else  if (flags & wxSD_REGULAREXPRESSION) {
        bResult = DoRESearch(input, startOffset, find_what, flags, posInChars, matchLenInChars);
        
    } else {
        bResult = DoSimpleSearch(input, startOffset, find_what, flags, posInChars, matchLenInChars);
    }
    
    // correct search Pos and Length owing to non plain ASCII multibyte characters
    if ( bResult ) {
        pos = UTF8Length(input, posInChars);
        if (flags & wxSD_REGULAREXPRESSION) {
            matchLen = UTF8Length(input, posInChars + matchLenInChars) - pos;
        } else {
            matchLen = UTF8Length(find_what, matchLenInChars);
        }
    }
    return bResult;
}
Beispiel #2
0
Char16
String::toChar16() const
{
	if (UTF8Length() != 1)
	{
		throwStringConversion(c_str(), "Char16");
	}
	return Char16(*this);
}