2024年1月14日发(作者:)
# encoding : utf-8def show_usage_and_exit(msg) puts "please input the path to zip" puts "error msg: #{msg}" exit 0enddef check_parameter show_usage_and_exit("no path to zip") unless == 1 show_usage_and_exit("path does not exist") unless ? ARGV[0].('utf-8') puts "===your input is===:n" + ARGV[0].('utf-8')enddef run_cmd(cmd) puts "===the command is===:n" + ("utf-8") + "nn---------- ------------n" puts `#{cmd}`.encode("utf-8") #puts `#{cmd}`enddef to_zip_cmd(input_str) if ory? input_str zip_output = input_str + ".zip" else zip_output = input_(/.w{2,4}z/,".zip") end zip_output if ? zip_output "#{%Q< "#{zip_("GBK")}" -r+ -cp 932 "#{input_("GBK")}">}"enddef to_unzip_cmd(input_str) "#{%Q< -cp 932 -d "#{e(input_str).encode("GBK")}" "#{input_("GBK")}">}"endcheck_parameterinput_str = ARGV[0].('utf-8') # ;puts ARGV[0]._encoding("GBK").encode('utf-8')if input__with? '.zip' run_cmd(to_unzip_cmd input_str)else run_cmd(to_zip_cmd input_str)end


发布评论