From 819fce6bdf23e654d839f2aa566d822653ea6689 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 15 Jan 2026 22:41:09 +0800 Subject: update iconv --- xmake/modules/cli/iconv.lua | 14 ++++++++++++-- 1 file 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 -- cgit v1.3.1