From a220f76ca922cd373d5769571371a224d147fa58 Mon Sep 17 00:00:00 2001 From: cjblomqvist Date: Thu, 27 Mar 2014 18:08:47 +0100 Subject: [PATCH] Add support for other charsets than utf-8 for output (for executable anyway) --- bin/uglifyjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/uglifyjs b/bin/uglifyjs index d8164ade..6ea04dbf 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -66,6 +66,7 @@ You need to pass an argument to this option to specify the name that your module .describe("V", "Print version number and exit.") .describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.") .describe("charset-input", "Charset of input (default utf-8)") + .describe("charset-output", "Charset of output (default utf-8)") .alias("p", "prefix") .alias("o", "output") @@ -370,9 +371,13 @@ async.eachLimit(files, 1, function (file, cb) { } if (OUTPUT_FILE) { - fs.writeFileSync(OUTPUT_FILE, output, "utf8"); + if(ARGS.charset_output) { + fs.writeFileSync(OUTPUT_FILE, iconv.encode(output, ARGS.charset_output)); + } else { + fs.writeFileSync(OUTPUT_FILE, output, "utf8"); + } } else { - sys.print(output); + sys.print(ARGS.charset_output ? iconv.encode(output, ARGS.charset_output) : output); } if (ARGS.stats) {