SQLite中的土耳其字符在使用LIKE表达式时

mcx*_*xxx 6 c# java sqlite android

select *from urunler where musteri like %ir%;
Run Code Online (Sandbox Code Playgroud)

测试数据:

+---musteri---+---ID--+
+-------------+-------+ 
+---?rem------+---1---+ 
+---Kadir-----+---2---+ 
+---Demir-----+---3---+ 
Run Code Online (Sandbox Code Playgroud)

返回结果:

Kadir
Demir 
Run Code Online (Sandbox Code Playgroud)

如果使用%?r%然后İrem返回,但卡迪尔和Demir没有回来.其他土耳其人的角色也有同样的问题,但没有任何确切的解决方案.我正在编程单声道android.


    [SQLiteFunction(Name = "TOUPPER", Arguments = 1, FuncType = FunctionType.Scalar)]
    public class TOUPPER: SQLiteFunction
    {
        public override object Invoke(object[] args)
        {
            return args[0].ToString().ToUpper();
        }
    }       

    [SQLiteFunction(Name = "COLLATION_CASE_INSENSITIVE", FuncType = FunctionType.Collation)]
    class CollationCaseInsensitive : SQLiteFunction {
        public override int Compare(string param1, string param2) {
            return String.Compare(param1, param2, true);
        }
    }       

TOUPPER.RegisterFunction(typeof(TOUPPER));
Run Code Online (Sandbox Code Playgroud)

用这种方式解决了,还单声道c#'使用了库,这里是我需要做的Android.Database.Sqlite.SQLiteDatabase

gfo*_*our 5

SQL中理解的SQL,"LIKE和GLOB运算符"部分:

对于超出ASCII范围的unicode字符,LIKE运算符默认区分大小写.

这意味着"İ"与"i"和"I"不同.


zap*_*apl 3

此类问题的一种解决方案是将文本的规范化版本保存到另一列中。在编写文本之前,INSERT将所有特殊字符替换为一些常见字符,并将两个版本都放入数据库中。

\n\n

你的桌子看起来像这样

\n\n
ID   musteri     musteri_normalized\n---  ----------  ------------------\n1    \xc4\xb0rem        Irem              \n2    Kadir       Kadir             \n3    yap\xc4\xb1lca\xc4\x9f    yapilcag \n
Run Code Online (Sandbox Code Playgroud)\n\n

现在,您可以LIKE对标准化列进行比较,并且仍然从数据库返回真实文本。

\n\n
SELECT musteri FROM table WHERE musteri_normalized LIKE '%ir%';\n-> \xc4\xb0rem, Kadir\n
Run Code Online (Sandbox Code Playgroud)\n