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 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.
In addition to saving under "UTF-8 without signature encoding", I had to switch to Windows style line endings (CR LF).
While viewing the .js file in Visual Studio 2008... File -> Advanced Save Options -> Unicode (UTF-8 without signature).
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.