Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why uglifyjs always compress unicode characters to utf8 #490

Closed
xiaoji121 opened this issue Jun 10, 2014 · 7 comments

Comments

Projects
None yet
5 participants
@xiaoji121
Copy link

commented Jun 10, 2014

before compress

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

after compress

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

This comment has been minimized.

Copy link
Author

commented Jun 10, 2014

it did not work when i set --ascii

@xiaoji121

This comment has been minimized.

Copy link
Author

commented Jun 10, 2014

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?

@mishoo

This comment has been minimized.

Copy link
Owner

commented Jun 10, 2014

Try -o ascii_only=true.

@mishoo mishoo closed this Jun 10, 2014

@hkongm

This comment has been minimized.

Copy link

commented Aug 13, 2014

totally not working...

@LeoYuan

This comment has been minimized.

Copy link

commented Aug 22, 2014

@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?

@rvanvelzen

This comment has been minimized.

Copy link
Collaborator

commented Aug 24, 2014

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

@LeoYuan

This comment has been minimized.

Copy link

commented Aug 26, 2014

@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!!!

brandonmp added a commit to brandonmp/crossbuilder that referenced this issue Oct 31, 2016

changed uglify options
2 changes here:  

1. i think `compressor` should be `compress`. i'm not sure if both work or not, but the (webpack docs)[http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin] say `compress`

2. `UglifyJS` unescapes `\u0000` and other unicode char code strings and converts them . this results in some libraries (`eg, `js-base64`, `firebase`) getting screwed up, and Chrome refusing to load the extension b/c the `injection` isn't `utf-8`. 

i hit that problem today and have been researching it. i could be wrong, but wanted to put in a PR to see what you thought

there's a `couchDB` bug that briefly explains it [here](pouchdb/pouchdb#5798)

the post that discusses the solution is on the `uglify` [repo here](mishoo/UglifyJS2#490)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.