3
I’m trying to optimize the organ site where I work and I’m facing problems after concatenating and minifying the Avascripts.
Our Apache server uses ISO-8859-1 and all my files in Phpstorm are configured in that same charset.
After doing the Concat and Uglify in Gulp (which worked correctly), I had problems with accentuation in some system functionalities, for example the "Datepicker" of jQuery-ui.
Where it should be written "Schedule" is "Hor? river".
I’ve tried using the "Gulp-Convert-encoding" and set it to ISO-8859-1, but it also didn’t work.
follows the stretch where I call the archives, concateno and minifico:
var js = [
'./msg/js/jquery-1.10.1.min.js',
'./placeholder/jquery-placeholder.js',
'./msg/js/msg.js',
'./enviarArquivo/js/ajaxupload.3.5.js',
'./funcoes/funcoes.js',
'../../../padroes/interface/scripts/shadowbox.js', // Padrão de interfaces
'./calendario/jquery-ui-1.10.3.custom.js',
'./calendario/jquery-ui-timepicker-addon.js',
'./combobox/chosen.jquery.js',
];
gulp.task('minify-js', function () {
gulp.src(js)
.pipe(concat('script.min.js'))
.pipe(convertEncoding({to: 'ISO-8859-1'}))
.pipe(uglify())
.pipe(gulp.dest('../pages/template/js/dist/'))
.pipe(notify('Javascript compilado e minificado!'));
});
I saw that when finished compiling, the file script.minjs. stands as UTF-8 and all accented characters are replaced by (?).
I was looking at Soen’s suggestion to use
stringfinal= decodeURIComponent(escape(stringinicial));
. Check it out if you can resolve: http://stackoverflow.com/a/5396742/2256325. Check it out here as well: https://www.npmjs.com/package/gulp-utf8-convert– Sergio
Hello, @Sergio. Thank you very much, but you can’t do it this way since there are thousands of lines of code to check. Another thing: any Alert that we try to use and that has accentuation also presents problem. All files are in ISO-8859-1 and only after running Gulp the file turns UTF-8.
– buback
And can’t convert the entire file string to UTF? Are you opening the file on Node? or receiving string content on Node?
– Sergio
@Sergio actually tried to convert the file but the error remains. I am not opening on Node. I am viewing directly by the site, which is in PHP.
– buback
Man to me you already identified the problem, "All files are in ISO-8859-1". Cannot convert files to UTF-8?
– KaduAmaral
Tried to enable the
ASCIIOnly
?– KaduAmaral
@Kaduamaral, thanks for the help. I have now tried to enable Asciionly and it also didn’t work. About converting the files into UTF8, I can’t. These files are used in various systems (actually I have no way of knowing how many) of a state public body. Any problem causes taxpayers, tax auditors and accountants, jam the phone. :(
– buback
I converted one of the files to UT8 to test and it really worked. I used . pipe(convertEncoding({to: 'ISO-8859-1'})) and saved min.js as ISO. I will seek to know what I can convert and try. Thank you for now.
– buback
@Buback Already tried to convert to UTF-8 before concatenating and to ISO after concatenating?
– Caputo
The default for any project is UTF-8, you don’t need to use ISO-8859-1 format, because of accentuation, this only forces you to have to convert characters to special formats. UTF-8 recognizes accentuation. No conversion required.
– Ivan Ferrer