c# - Turkish character in SQLite while using LIKE expression -
select *from urunler musteri %ir%;
test data:
+---musteri---+---id--+ +-------------+-------+ +---İrem------+---1---+ +---kadir-----+---2---+ +---demir-----+---3---+
returning result:
kadir demir
if use %İr%
İrem returning kadir , demir not returning. there same problem in other turkish characters, not exact solution. 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));
solved in way, mono c # 'using library, here how need android.database.sqlite.sqlitedatabase
one solution such problem saved normalized version of text column. before insert
text replace special characters common character , put both versions in database.
your table looks then
id musteri musteri_normalized --- ---------- ------------------ 1 İrem irem 2 kadir kadir 3 yapılcağ yapilcag
now can use like
comparison on normalized column , still return real text database.
select musteri table musteri_normalized '%ir%'; -> İrem, kadir
Comments
Post a Comment