sqlite讀取中文亂碼(C#)


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM