在UWP和Sqlite中使用uft-8字符搜索查询

时间:2017-02-22 14:28:54

标签: c# utf-8 uwp sqlite-net

对于相同的搜索查询

select * 
from Dictionary 
where vi_Name like '%quả táo%'

当我在SQLite中运行查询时,它返回一条记录,但是当我将同一个查询复制到uwp并运行它时,我得到“No record found”。如果我切换到英文字母(a-zA-Z),查询搜索正常,但没有结果像àá那样的utf-8字符......可能有什么不同?

这是我的代码:

public class Dictionary
{
     public string en_Name { get; set; }
     public string vi_Name { get; set; }
}

SQLite.Net.SQLiteConnection conn;

public MainPage()
{
    this.InitializeComponent();

    string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "dictionary.db");
    conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
}

private void btnFind_Click(object sender, RoutedEventArgs e)
{
    List<Dictionary> result = conn.Query<Dictionary>(@"select * from Dictionary where vi_Name like '%quả táo%'");

    if(result .Count > 0)
        txtEqual.Text = result[0].en_Name.ToString();
}

0 个答案:

没有答案