|
三个月以前就知道MUSHclient4.40提供了SQLite的API,MUSH有了SQLite的支持会更强大,但实际使用中却发现,SQLITE内部数据的存储是UTF-8的,而MUD里抓出来的文字都是GB2312的,实际使用SQL语句查询的时候(尤其是模糊查询)根本不会有正确的结果,郁闷了好久(最后改回了ACCESS),今天终于找到了解决的办法!
luaiconv
根据GAMMON的贴子以及前段时间duno关于dll编译的帮助,改写了luaiconv.c,重新编译成.dll文件,MUSH已经可以正常调用了,调用的例子如下:
-
- function test_iconv()
-
- assert (package.loadlib ("luaiconv.dll", "luaopen_iconv")) ()
-
- local cd = iconv.open("UTF-8", "GB2312") -- set the codeset's convertion is from GB2312 to UTF-8.
-
- local text = "中国"
-
- local outstr, err = cd:iconv(text) -- call iconv() method to convert the text's codeset.
-
- if err == iconv.ERROR_INCOMPLETE then
- print("ERROR: Incomplete input.")
- elseif err == iconv.ERROR_INVALID then
- print("ERROR: Invalid input.")
- elseif err == iconv.ERROR_NO_MEMORY then
- print("ERROR: Failed to allocate memory.")
- elseif err == iconv.ERROR_UNKNOWN then
- print("ERROR: There was an unknown error.")
- end -- if;
-
- print(outstr)
- print(err)
-
- end -- test_iconv()
复制代码
下面就要开始我的SQLITE之旅了…… |
|