C#讀取一些C++創建的sqlite數據庫時亂碼, C++保存DB是用GB2312編碼的, C#調用的官方的system.data.sqlite是用的UTF-8編碼的, 在讀取時會亂碼, 用一個GB2312編碼的system.data.sqlite就行了.
可以下載sqlite源碼修改重編譯dll
修改SQliteConvert.cs line52
//private static Encoding _utf8 = new UTF8Encoding();
private static Encoding _utf8 = System.Text.Encoding.GetEncoding("GB2312");
ADO.NET 2.0 Provider for SQLite 1.0.66.0
1.066.0中少個mergebin.exe, 在老版本的1.0.61.0中有. VS2008下載
已經編譯好的讀取GB2312數據庫的DLL(下載), 解壓后選擇合適的dll, 改名為System.Data.SQLite.dll再使用.
參考:
1.http://blog.sina.com.cn/s/blog_63edfc900100snvw.html
2.vs2008 C# 使用 System.Data.SQLite.dll 字符編碼問題
http://topic.csdn.net/u/20090601/11/9edb203e-ae0e-41d8-b21f-cd6147f31408.html
3.vs2008如何編譯完整的System.Data.SQLite.dll
http://topic.csdn.net/u/20090603/09/2236072b-da66-459b-b175-fc4676fe984f.html