cgutierrez / JsMinifier

Sublime Text plugin for javascript minification using Google Closure compiler
131 stars 18 forks source link

Unicode Error #7

Open jfreyre opened 12 years ago

jfreyre commented 12 years ago

Hi,

I am a french speaker and when I try to minify my files, I get an error about accentued chars like 'à' or 'é'

Here is the exception thrown in the console:

Exception in thread Thread-29:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "./compilers/basecall.py", line 22, in run
  File "./compilers/googleclosurecall.py", line 12, in exec_request
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py", line 1281, in urlencode
    v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 188: ordinal not in range(128)

error: There was an error minifying the Javascript.
Warning: Double finish

And a sample of script that fail:

$(document).ready(function () {
    $('div').append('à')
});

Hope it helps... ;)

cgutierrez commented 12 years ago

I've pushed a small fix. At the moment, it will convert characters like 'à' in to their utf-8 codes. The biggest issue with that is that it making changes to your JS before submitting it to the compiler. I'll see if I can find a different work around but as far as I can tell, this works for now.

for example... your code of:

$(document).ready(function () { $('div').append('à') });

becomes...

$(document).ready(function () { $('div').append('\u00e0') });

jotapepinheiro commented 12 years ago

Awaiting a solution to this problem.

With AjaxMin I use a bat file as well. AjaxMin.exe arquivo.js it arquivo.min.js -clobber -enc: in iso-8859-1 -enc: out iso-8859-1

http://ajaxmin.codeplex.com/