使用SQLite和WinForms 2.0 C#编码问题问题、SQLite、WinForms

2023-09-04 05:34:21 作者:③分清醒⑦分醉

我正在开发使用。NET 2.0 WinForms应用程序,并想使用SQLite作为一个数据库解决方案。我的主要问题是,我无法看到的数据从数据库在WinForm当数据在非英语语言(在我的情况下,希腊)。

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).

有关数据库管理目的,我使用的SQLite管理员有没有问题在希腊所有的返回数据。但是,当我在我的表单一个DataGridView加载数据,我得到那些可怕的缺字方形符号。

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.

为了与我使用 System.Data.SQLite 解决方案数据库进行通信。

In order to communicate with the db I use the System.Data.SQLite solution.

有我丢失的东西吗?我看了设置的默认排序规则在数据库中,但并没有拿出任何东西,因为SQLite不支持像SQL Server排序规则值(例如COLLATE Greek_CI_AS)

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)

感谢

P.S。我使用的SQLite 3和System.Data.SQLite.dll 1.0.60。用于测试的连接字符串: 数据源= test.db的; UseUTF8Encoding = TRUE;

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;

推荐答案

您检索一个字符串,或从数据库中的字节数组?在内部,SQLite的使用UTF-8或UTF-16字符串(这取决于哪种方法被用于插入串入数据库),这是当你使用sqlite3_column_text得到一个字符串值,它返回。

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.

在另一方面,如果你问一个blob,这将直接返回底层字节,其性格可能不匹配的编码应用程序期待。

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.

我不知道如何对这些底层操作的ADO提供地图,但在我看来,如果你的文本不被返回UNI code,或者它是,但应用程序以其他方式处理它,这可能是问题的症结所在。

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

编辑:当我想起来了,尝试 SQLiteman 打开你的数据库,以查看是否有任何区别。

While I think of it, try opening your database in SQLiteman, to see if there is any difference.