private string FirstPassFilterString(string sMatch)
{
if (m_rbtnUseRegExp.Checked || !m_chkMatchCase.Checked)
return "%"; // can we do better?
var sb = new StringBuilder(sMatch);
if (!m_chkMatchDiacritics.Checked)
{
// Allow any number of diacritics (or other chars for that matter, alas) between
// every nondiacritic character in the string.
for (int ich = sb.Length - 1; ich > 0; --ich)
{
if (Icu.IsDiacritic(sb[ich]))
sb[ich] = '%';
else
sb.Insert(ich, '%');
}
}
// Add beginning and ending wildcards as needed.
if (m_rbtnAnywhere.Checked || m_rbtnAtEnd.Checked)
sb.Insert(0, '%');
if (m_rbtnAnywhere.Checked || m_rbtnAtStart.Checked)
sb.Append('%');
// Get rid of any doubled wildcard markers. Doing this 3 times reduces as many as
// 8 consecutive markers to a single one.
sb.Replace("%%", "%");
sb.Replace("%%", "%");
sb.Replace("%%", "%");
// Double single quotes to quote them as part of an SQL string.
return sb.ToString().Replace("'", "''");
}