Hi guys,
When I try to use lua's file write function, I get this question.
Lua code like following, and it is very simple.
local filename = [[./test1.txt]]
local clean_code_lines = {"aa", "bb", "cc", "dd"}
local f = io.open(filename, "w")
for li = 1, #clean_code_lines do
f:write(clean_code_lines[li])
f:write("\r\n")
end
f:close()
And you could notice the open function's parameter is "w", it means I want
to write text file.
When I run this script in windows (I build the lua with VC2008), it will get
result like:
aaCR
CRLF
bbCR
CRLF
ccCR
CRLF
ddCR
CRLF
The CR is "\r", the LF is "\n", and they can't display in mail, so I use
string to replace.
I trace the Lua binary code generating, it seems correct.
And I have a Mac ibook G4, so I test the same script in G4, it could get
result like:
aaCRLF
bbCRLF
ccCRLF
ddCRLF
It is the correct result what I want.
So my question is, why the script get incorrect(?) result in windows?
Is the issue in windows's fwrite function?
Thanks,
Will Sun