|
using System.Data.SQLite;
using System.Globalization;
namespace SQLiteUTF8CIComparison {
/// <summary>
/// This function adds case-insensitive sort feature to SQLite engine
/// To initialize, use SQLiteFunction.RegisterFunction() before all connections are open
/// </summary>
[SQLiteFunction(FuncType = FunctionType.Collation, Name = "UTF8CI")]
public class SQLiteCaseInsensitiveCollation : SQLiteFunction {
/// <summary>
/// CultureInfo for comparing strings in case insensitive manner
/// </summary>
private static readonly CultureInfo _cultureInfo = CultureInfo.CreateSpecificCulture("ru-RU");
/// <summary>
/// Does case-insensitive comparison using _cultureInfo
/// </summary>
/// <param name="x">Left string</param>
/// <param name="y">Right string</param>
/// <returns>The result of a comparison</returns>
public override int Compare(string x, string y) {
return string.Compare(x, y, _cultureInfo, CompareOptions.IgnoreCase);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.