为什么 Sass 在前面加上不正确的 @charset 规则? [英] Why does Sass prepend an incorrect @charset rule?
问题描述
我用
sass --watch scss:css
让 Sass 为每个 SCSS 文件(来自我的 /scss
目录)自动创建 CSS 文件(并将它们放在 /css
目录中).
to have Sass automatically create CSS files (and put them in the /css
directory) for each SCSS file (from my /scss
directory).
在我的 SCSS 文件中,我有这个:
In my SCSS file I have this:
.foo::before {
content: "▶";
}
当我在浏览器中测试网页时,没有显示播放"字符 - 相反,我看到了一堆带有卡隆和其他口音的奇怪字母.
When I test the web page in the browser, that "play" character is not displayed - instead I see a bunch of weird letters with carons and other accents.
我检查了生成的 CSS 文件并在第一行注意到了这一点:
I inspected the generated CSS file and noticed this in the first line:
@charset "CP852";
然后我手动将其更改为:
I then manually changed that to this:
@charset "UTF-8";
这导致我的播放"按钮被正确呈现.
which resulted in my "play" button being rendered correctly.
现在,为什么 Sass 将字符集设置为 "CP852"
?我正在用 PhpStorm 编写 SCSS 文件,它报告 SCSS 文件确实是 UTF-8 编码的(我在 PhpStorm 的状态栏中看到了这一点).
Now, why does Sass set the charset to "CP852"
? I'm writing the SCSS file in PhpStorm which reports that the SCSS file indeed is UTF-8 encoded (I see that in the status bar of PhpStorm).
推荐答案
尝试将 @charset "UTF-8";
添加到您的原始 SCSS 文件中,SASS 不应覆盖它/添加自己的那么.
Try adding @charset "UTF-8";
to your original SCSS file, SASS shouldn't override it/add its own then.
这篇关于为什么 Sass 在前面加上不正确的 @charset 规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!