Truncate a file: Difference between revisions

Content added Content deleted
(Added Lua version)
m (Clarified explanation)
Line 551: Line 551:
=={{header|Lua}}==
=={{header|Lua}}==
Lua strings treat each byte as being invariably one whole character (hence the awkwardness of trying to use it with unicode), so it's safe to use string methods to truncate binary data.
Lua treats strings as being invariably one byte per character (hence the awkwardness of trying to use it with unicode), so it's safe to use string methods to truncate binary data.
<lang Lua>function truncate (filename, length)
<lang Lua>function truncate (filename, length)
local inFile = io.open(filename, 'r')
local inFile = io.open(filename, 'r')