summaryrefslogtreecommitdiff
path: root/xmake/modules/cli
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/cli')
-rw-r--r--xmake/modules/cli/iconv.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/xmake/modules/cli/iconv.lua b/xmake/modules/cli/iconv.lua
index cc79bd934..a494155ed 100644
--- a/xmake/modules/cli/iconv.lua
+++ b/xmake/modules/cli/iconv.lua
@@ -50,10 +50,20 @@ function main(...)
-- get arguments
local input_file = assert(args.inputfile, "input file required!")
- local output_file = assert(args.outputfile, "output file required!")
+ local output_file = args.outputfile
local from_code = args.from
local to_code = args.to
-- convert encoding
- io.convert(input_file, output_file, {from = from_code, to = to_code})
+ if output_file then
+ io.convert(input_file, output_file, {from = from_code, to = to_code})
+ else
+ local tmpfile = os.tmpfile()
+ io.convert(input_file, tmpfile, {from = from_code, to = to_code})
+ local data = io.readfile(tmpfile, {encoding = "binary"})
+ if data then
+ io.write(data)
+ end
+ os.rm(tmpfile)
+ end
end