Uglifyjs: why uglifyjs always compress unicode characters to utf8

Created on 10 Jun 2014  ·  7Comments  ·  Source: mishoo/UglifyJS

before compress

Wing.navigator.tooltip('\u518d\u6309\u4e00\u6b21\u9000\u51fa\u4f19\u62fc')

after compress

Wing.navigator.tooltip("再按一次退出伙拼")

Most helpful comment

@rvanvelzen @hkongm
My bad, I have to admit that I didn't read the doc very carefully, just to remind others who ran into my situation.

CLI:

uglifyjs uglifyjs-test.js -o tmp.min.js -b beautify=false,ascii-only=true

Programatical way:

uglifyjs.minify('var chinese = "\u4e2d\u6587"', {
    fromString: true,
    output: {
        "ascii_only": true
    }
})

Once more, plz read the doc carefully before using it!!!

All 7 comments

it did not work when i set --ascii

i found ascii_only changed to ascii-only in uglifyjs2,but i didn't find this option in source code.

Is uglifyjs2 not support this option?

Try -o ascii_only=true.

totally not working...

@mishoo
Not sure if you have ever tried this feature, it is absolutely not working!

And I searched for ascii-only / ascii_only / ascii in the source code, none of these words found.

Could u make a double check on this issue?

@LeoYuan Are you sure you're using version 2 and not 1? The option is definitely there there and working.

@rvanvelzen @hkongm
My bad, I have to admit that I didn't read the doc very carefully, just to remind others who ran into my situation.

CLI:

uglifyjs uglifyjs-test.js -o tmp.min.js -b beautify=false,ascii-only=true

Programatical way:

uglifyjs.minify('var chinese = "\u4e2d\u6587"', {
    fromString: true,
    output: {
        "ascii_only": true
    }
})

Once more, plz read the doc carefully before using it!!!

Was this page helpful?
0 / 5 - 0 ratings