diff options
| author | ruki <[email protected]> | 2026-01-15 22:41:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-15 22:41:09 +0800 |
| commit | 819fce6bdf23e654d839f2aa566d822653ea6689 (patch) | |
| tree | d1d3a6becf26383595577e3ab3467299b00368b9 /xmake/modules/cli/iconv.lua | |
| parent | b9423c81cc0256e435e6337aa4d55b0ad5ec3784 (diff) | |
update iconv
Diffstat (limited to 'xmake/modules/cli/iconv.lua')
| -rw-r--r-- | xmake/modules/cli/iconv.lua | 14 |
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 |
