I am getting some errors when trying to run yuicompressor.
it says:
[error] 1:2:illegal character
[error] 1:2:syntax error
[error] 1:3 illegal character
Could this be because I am saving it as the wrong encoding or something?
I have seen issues with YUICompressor and files that are saved in UTF-8 with the Byte Order Mark (BOM). The default for Visual Studio 2008 seems to be to save them this way. To solve it, I had to save the file with a different encoding. In VS2008, this was File - Advanced Save Options - Encoding : Unicode (UTF-8 without signature) .
I ran across this issue today. Another fix is to provide the --charset utf-8
option on the command line.
除了在“没有签名编码的UTF-8”下保存,我不得不切换到Windows样式行结尾(CR LF)。
在Visual Studio 2008中查看.js文件时...文件 - >高级保存选项 - > Unicode(不带签名的UTF-8)。
I've had the same problem with encodings using the .NET version of the YuiCompressor.
Fixed adding the EncodingType="UTF8"
in my configuration file:
<CssCompressorTask EncodingType="UTF8" SourceFiles="@(CssFiles)" OutputFile="path\styles.min.css" />
<JavaScriptCompressorTask EncodingType="UTF8" SourceFiles="@(JavaScriptFiles)" OutputFile="path\scripts.min.js" />
For more encoding options, see the docs .
Just in case anyone is using Powershell to concatenate files, I used the following Powershell script to circumvent this problem:
Get-Content `
JavaScript/file01.js,`
JavaScript/file02.js,`
JavaScript/file03.js `
| Set-Content JavaScript/Concat.js -Encoding Ascii
java.exe -jar ../../yuicompressor/build/yuicompressor-2.4.2.jar JavaScript/Concat.js -o JavaScript/Concat.min.js preserve-semi --charset ascii --type js
Notice the ascii encoding parameters on both the concatenation and YUICompressor call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.