Byte Order Mark (BOM) is written to the file when "utf8" or "unicode" encoding is used.
Edit:save(file, [isrichtext], [encoding])method
Saves the Edit content to a specified file.
Parameters
file
A File object or a filename string, representing the file whose content will fill the Edit.
[isrichtext]
An optional boolean value indicating wether the file content is in RichText format, or not.
[encoding]
An optional string indicating the desired file encoding (See File:open() for possible encoding values). If omitted, uses default raw binary encoding.
Return value
This function returns true if it succeeds or false if it fails.Example
--! luart-extensions
import ui
-- create a simple window
local win = ui.Window("Edit.save sample", "fixed", 520, 460)
local button = ui.Button(win, "Save as unicode",210, 10)
local edit = ui.Edit(win, "", 10, 44, 500, 410)
edit.font = "Courier New"
edit.fontsize = 8
edit.wordwrap = true
function button:onClick()
local file = ui.savedialog()
if file ~= nil then
edit:save("test.txt", "unicode")
end
end
win:show()
-- update user interface
repeat
ui.update()
until not win.visible