grunt-contrib-sass: incompatible character encodin

2019-02-15 16:18发布

问题:

While trying to use grunt to convert my sass files into normal css files i get the warning:

Warning: Encoding::CompabilityError: incompatible character encodings: UTF-8 and CP850.

However when I run sass calling the file(s) everything works as it should even though no encoding is specified by me. My Gruntfile.js looks like this:

[...]
sass: {
    main: {
        files: {
            'css/theme/default.css': 'css/theme/source/default.scss',
                'css/theme/beige.css': 'css/theme/source/beige.scss',
            'css/theme/night.css': 'css/theme/source/night.scss',
            'css/theme/serif.css': 'css/theme/source/serif.scss',
            'css/theme/simple.css': 'css/theme/source/simple.scss',
            'css/theme/sky.css': 'css/theme/source/sky.scss',
            'css/theme/moon.css': 'css/theme/source/moon.scss',
            'css/theme/solarized.css': 'css/theme/source/solarized.scss',
            }
        }
    }
[...]

which is a part of the Gruntfile.js I forked from the reveal.js on GitHub. I took a look at the grunt-contrib-sass on GitHub and tried to find the option to change the encoding manualy. However it apears that there is none (maybe I just overlooked it?). I think a keypart of the problem is that I am using Windows 8 and not any Unix based OS.

So my question is: How do i get rid of this warning? Or how do i fix the code to work properly? Any help is appreciated.

回答1:

I had this error when trying to use the command:

sass --watch global.scss:global.css --style compressed

And the cause was the most stupid cause ever... I had this folder: E:\Dropbox[Websites][External] Fundación Global\css and I run the command in there, and SASS returned this same error: Warning: Encoding::CompabilityError: incompatible character encodings: UTF-8 and CP850.

I just needed to take out the ó from the folder's path!

That simple and silly! Just changed this: ...Fundación Global\css for this ...Fundacion Global\css and I have SASS watching with no issues again.