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
此类问题的一种解决方案是将文本的规范化版本保存到另一列中。在编写文本之前,INSERT
将所有特殊字符替换为一些常见字符,并将两个版本都放入数据库中。
你的桌子看起来像这样
\n\nID 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
对标准化列进行比较,并且仍然从数据库返回真实文本。
SELECT musteri FROM table WHERE musteri_normalized LIKE '%ir%';\n-> \xc4\xb0rem, Kadir\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
2177 次 |
最近记录: |