使用SQLite和WinForms编码问题2.0 C# [英] Encoding problem using SQLite and WinForms 2.0 C#
问题描述
对于数据库管理目的是使用 SQLite管理员,它在希腊所有返回的数据中都没有任何问题。但是当我以我的形式加载DataGridView中的数据时,我会收到那些可怕的缺少的字符的方形符号。
为了与数据库通信,我使用系统。 Data.SQLite 解决方案。
我在这里遗漏了什么?我寻找设置数据库中的默认排序规则,但没有提出任何内容,因为SQLite不支持诸如SQL Server之类的排序规则值(例如COLLATE Greek_CI_AS)
谢谢
PS我使用SQLite 3和System.Data.SQLite.dll 1.0.60。测试的连接字符串是:
Data Source = test.db; UseUTF8Encoding = True;
您是从数据库检索一个字符串还是一个字节数组?在内部,SQLite使用UTF-8或UTF-16字符串(取决于使用哪种方法将字符串插入到数据库中),当使用sqlite3_column_text获取字符串值时,它将返回它。
另一方面,如果您要求一个blob,它将返回底层字节,这可能与应用程序期望的字符编码可能不一致。
我不知道ADO提供商如何映射到这些基础操作,但是在我看来,如果你的文本没有被返回为unicode,或者是应用程序正在处理它,否则可能是问题所在。
http: //www.sqlite.org/c3ref/column_blob.html
编辑:虽然我想到,尝试打开你的数据库在 SQLiteman 中查看是否有任何差异。
I am developing a WinForms app using .NET 2.0 and am trying to use SQLite as a DB solution. My main problem is that I have trouble seeing data from the DB in the WinForm when the data is in a non english language (in my case greek).
For db administration purposes I use the SQLite administrator which has no trouble at all returning data in greek. But when I load the data in a DataGridView in my form, I get those dreaded "missing character" square symbols.
In order to communicate with the db I use the System.Data.SQLite solution.
Is there something I am missing here? I looked for setting the default collation in the database but did not come up with anything, since SQLite does not support collation values like SQL Server (e.g. COLLATE Greek_CI_AS)
Thanks
P.S. I am using SQLite 3 and System.Data.SQLite.dll 1.0.60. The connection string for the test is:
Data Source=test.db;UseUTF8Encoding=True;
Are you retrieving a string, or a byte array from the database? Internally, SQLite uses UTF-8 or UTF-16 strings (depending on which method was used to insert the string into the database) which is what it returns when you get a string value using sqlite3_column_text.
On the other hand, if you ask for a blob, it will just return the underlying bytes, which may not match the character encoding your application is expecting.
I'm not sure how the ADO provider maps on to these underlying operations, but it seems to me that if your text isn't being returned as unicode, or it is but the app is treating it otherwise, that may be where the problem lies.
http://www.sqlite.org/c3ref/column_blob.html
Edit: While I think of it, try opening your database in SQLiteman, to see if there is any difference.
这篇关于使用SQLite和WinForms编码问题2.0 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!