Reading from a text file and then printing the lines. The simulator on MacOS outputs an extra number of letters.
local filePath = system.pathForFile( textFile, system.ResourceDirectory ) local file = io.open( filePath, "rb" ) for lines in file:lines() do print("Lines = ", lines, #lines) end
This is what is sent to the simulator output window. You can see it prints lines and then starts #lines on a new line (print must be recognising the carriage return symbol as such). Then the number on a new line is listed as 1 too many.
Sep 28 09:17:01.994 Lines = \<p2\_1 6 Sep 28 09:17:01.994 Lines = Some of the critters can be GIGANTIC! 38 Sep 28 09:17:01.994 Lines = 1 Sep 28 09:17:01.994 Lines = \<p2\_2 6
Opening the text in textMate shows the addition of <CR> after every new line. This is due to the text file being edited in Windows and saved as a windows text format.
Question, how to identify these trash characters in Corona or is there a program or text encoding that can remove these characters?