简体   繁体   English

缩小javascript弄乱字符

[英]minifying javascript messes up characters

I am trying to minify a .js file that includes code like this: 我试图缩小包含以下代码的.js文件:

DIACRITICS = {"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE", ....

The problem is, when I use a tool like http://javascript-minifier.com/ or http://refresh-sf.com/ to minify it, the above code gets changed to this: 问题是,当我使用诸如http://javascript-minifier.com/http://refresh-sf.com/之类的工具来缩小它时,上面的代码被更改为:

,j={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą"

I assume that will cause problems when it executes? 我认为执行时会引起问题吗? Is there any way around this? 有没有办法解决?

Try using Microsoft's AjaxMinifier: http://ajaxmin.codeplex.com/ 尝试使用Microsoft的AjaxMinifier: http ://ajaxmin.codeplex.com/

This is to do with encoding, so use the program with the "-enc:out ascii" command. 这与编码有关,因此请将该程序与“ -enc:out ascii”命令一起使用。

Once you download the program, open it. 下载程序后,将其打开。 It will appear like a command prompt window. 它将显示为命令提示符窗口。 CD to the directory of your JS file, then run: CD到您的JS文件的目录,然后运行:

ajaxminifier file.js -o file.min.js -enc:out ascii

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM