同时采用像前pression SQLite中土耳其字符 [英] Turkish character in SQLite while using LIKE expression

查看:129
本文介绍了同时采用像前pression SQLite中土耳其字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select *from urunler where musteri like %ir%;

测试数据:

+---musteri---+---ID--+
+-------------+-------+ 
+---İrem------+---1---+ 
+---Kadir-----+---2---+ 
+---Demir-----+---3---+ 

返回结果:

Kadir
Demir 

如果使用%IR%然后IREM正在恢复,但卡迪尔和德米尔没有返回。在其他土耳其字符有同样的问题,但没有任何具体的解决方案。我编程单机器人。

if use %İr% then İrem is returning but Kadir and Demir not returning. There same problem in other turkish characters, but not any exact solution. I am programming mono 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));

解决了这种方式,而且单C#使用库,这里是我需要做的Andr​​oid.Database.Sqlite.SQLiteDatabase

solved in this way, but also mono c # 'using the library, here is how I need to do Android.Database.Sqlite.SQLiteDatabase

推荐答案

有这样的问题,一种解决方案是保存的文本的规范化版本到另一列。在你插入替换所有的特殊字符一些常见的字符,并把两个版本在数据库中的文本。

One solution for such a problem is to saved a normalized version of the text into another column. Before you INSERT the text you replace all special characters with some common character and put both versions in the database.

您表看起来像那么

ID   musteri     musteri_normalized
---  ----------  ------------------
1    İrem        Irem              
2    Kadir       Kadir             
3    yapılcağ    yapilcag 

现在,您可以使用 LIKE 比较归一化列,仍然会返回从数据库中真正的文本。

Now you can use LIKE comparison on the normalized column and still return the real text from the database.

SELECT musteri FROM table WHERE musteri_normalized LIKE '%ir%';
-> İrem, Kadir

这篇关于同时采用像前pression SQLite中土耳其字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆