luacom GetEnumerator 不好使?

上一篇說了luacom不支持gbk,不過可以用iconv來解決,但是我還發現了一個問題,貌似 enumerator 不太好使

require "luacom"
require "luaiconv"

function createIconv(to, from)
	local cd = iconv.new(to, from)
	return function(txt)
		return cd:iconv(txt)
	end
end

L = createIconv("utf-8", "gbk")
Z = createIconv("gbk", "utf-8")

fs = luacom.CreateObject("Scripting.FileSystemObject")
fd = fs:GetFolder("F:\\temp")

fenum = luacom.GetEnumerator(fd.Files)

f = fenum:Next()
while f do
	print(Z(f.Path))
	print(fs:FileExists(f.Path))
	f = fenum:Next()
end

(上面的代碼,改用luacom.pairs枚舉也有同樣問題)


這個代碼假設 F:\temp下面有中文文件名的文件,發現 Z 函數對中文文件名文件,總是返回錯誤,而 Enumerator獲得的路徑名,直接判斷是不是存在,居然是false!

這是什麼問題呢,同樣的方式,用javascript實現,完全沒有問題啊。


求高手解答! bug??(本人實在不瞭解COM,沒有勇氣看luacom源代碼)



發佈了52 篇原創文章 · 獲贊 5 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章