Hi All,
I'm trying to write a newline to a file...I have done this many times before on other platforms...but for some reason, this doesn't seem to be working! I
I am using
local file = io.open("P:/Gideros/Projects/test1.txt","w")
for i = 1, 10, 1 do
file:write("\n")
end
file:close()
I can write 10 "CATS" to the file, no problem....but I can't write newlines.
Thanks for any help you can provide
Comments
I tried char(10) (newline) and char(13) (carriage return)...neither worked =/
string.char(13) .. string.char(10)
I tested this, and it should work.
The fact that I can write anything to the file BUT a newline is what has me stumped.
write("1" .. "\n" .. "2") will write
"12"
to the file, rather than
"1
2"
There isn't any character encoding I should be setting (e.g. UTF-8 or anything)?
Gideros writes Unix style newlines even when running on Windows. However, it can read in newlines of any type so this rarely causes any practical difficulty.
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
thanks for the reply. I'm also reading the same file using:
for line in io.lines("P:/Gideros/Projects/test1.txt") do
print(line)
end
and it only finds one line (i.e. after it removes all the newlines and prints everything into one line)
So i really wonder about this.
Could you check using hex editor to make sure what character appears when you write a newline?