File.encoding readonly property



The File.encoding property returns the current file encoding. File should have been opened before to determine it's encoding or the property defaults to "binary" otherwise.

File encoding is one of those strings :
  • "binary" encoding : the File has no encoding, using raw bytes for read/write operations.
  • "utf8" encoding : the File is UTF8 encoded, using UTF8 characters for read/write operations.
  • "unicode" encoding : the File is UNICODE (UCS-2 LE) encoded, using UNICODE characters for read/write operations.

Example

local file = sys.File("unicode.txt") file:open("write", "unicode") file:write("Hello World !") file:close() file:open("read") -- outputs "unicode" print(file.encoding)