I have tried but output nothing to the temp file.
Its size is zero.
But when I run the code in command line,it output correct result.
Maybe it is because of asynchronize http request.
I don't know the root cause.

I want to translate text between gbk and utf8 .
The text from mud is encoded in GBK but I handle It in lua in utf8
It works in Windows command line
I have installed lua5.1 by full package with an installer

2.Fengxianpoem.lua
Fetech some data and parse it by keyword,save the result into a text file.

local keyword = "You failed when you get these words"
local filePath --full file path for writing result
if #arg>1 then
filePath = arg[2]
keyword = arg[1]
--print("keyword:"..keyword)
--print("filePath:"..filePath)

-- answerPoem5 fetech http page and parse it to result text,and write it to file.
----***luaiconv**** is called in this function.This is what I want.
---The lua script is running in command line so it works like that in command line.
local result = answerPoem5(keyword)
if not result then
result = ""
end
local fileHandle = assert(io.open(filePath,"w+"),"failed to open file")
--delay()
if fileHandle then
print("result:"..result)
fileHandle:write(result)
--delay()
fileHandle:close()
end
end