lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Mar 24, 2022 at 4:51 PM Thijs Schreijer wrote:
This means that reading a Windows based text file, with CRLF as
line endings, the returned lines will have a trailing CR (char 13).

I can not reproduce this problem.
Everything works as expected on Windows.

Lua 5.4.3  Copyright (C) 1994-2021 Lua.org, PUC-Rio
> s="AAA\nBBB"
> io.open("file.txt", "w"):write(s):close()
true
> io.open("file.txt", "rb"):read"*a":byte(1,-1)
65      65      65      13      10      66      66      66
> f=io.open("file.txt", "r")
> f:read"*l":byte(1,-1)
65      65      65
> g=io.open("file.txt", "rb")
> g:read"*l":byte(1,-1)
65      65      65      13