sqlite

关于SQLite中文乱码的处理

六眼飞鱼酱① 提交于 2020-11-13 20:39:01
最近一个项目中,同事用的是C往SQLite写入的数据,保存中文时用的是双字节的ASCII码。而我的程序是用C#写的,一开始没注意到这个问题,所以读取中文一直乱码。 在C#中好像没有找到合适的函数可以直接将双字节的ASCII码转成中文,然后考虑是否通过反向的思路看看是否可以将字节码转回中文,首先是通过SQLite的hex()函数将中文数据直接按16进制串返回。 SELECT transaction_serial_number,card_number,update_time,deal_result,hex(customer_name) as customer_name, .... 然后再将数据16进制转回10进制,再转回中文 /// <summary> /// 将16进制串转10进制字节数组 /// </summary> /// <param name="input"></param> /// <returns></returns> public static byte[] HexStringToByteArray(string input) { input = input.Replace(" ", "").Trim().ToUpper(); byte[] buffer = new byte[input.Length / 2]; for (int i = 0; i < input

sqlite DLL load failed

故事扮演 提交于 2020-11-12 16:19:20
2.解决办法如下: 1.解决方法一: 配置环境变量**\ Anaconda3 \ Library \ bin**的路径,(这里根据自己的主机路径配置) 2.解决方法二: 如果上面解决不了,就直接将 sqlite3.dll 拷贝到DLLS文件夹下面。 \ Anaconda \ Dlls \”中缺少 sqlite3.dll 引起的。通过从**\ Anaconda3 \ Library \ bin**复制该.dll文件并将其放在上述路径下即可解决该问题。 In [1]: import sqlite3 ---------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-5239c6be4108> in <module> ----> 1 import sqlite3 D:\Anaconda\lib\sqlite3\__init__.py in <module> 21 # 3. This notice may not be removed or altered from any source distribution. 22 ---> 23 from sqlite3.dbapi2 import * D: