2014-05-21 3 views
2

파이썬에서 sass를 호출하려고하는데 작동하도록 고심하고 있습니다. 내 CLI에서 다음 명령을 실행하면Sass 기본 인코딩 오류

가 작동 : 나는 다음과 같은 오류가

import subprocess 
subprocess.check_output(['sass', '/path/to/style.scss', '/path/to/style.css', '--style=compressed']) 

: 내 파이썬 스크립트를 통해 호출 할 때까지

sass /path/to/style.scss /path/to/style.css --style=compressed

이 작동

enc를 가진 각 파일의 상단에 @charset "UTF-8";을 추가하여 문제를 해결할 수 있음을 읽었습니다. 잘못된 오류.

문제는 파일이 많고 많은 패키지가 bower 패키지에 포함되어있어 추가하는 것이 가장 좋은 방법이 아니라는 것입니다. ,

ArgumentError: unknown encoding name - "UTF-8"

누구나 다른 해결 방법을 알고

은 내가 말대꾸 할 수있는 다음과 같은 옵션을 추가 할 수 있습니다 읽었습니다 : --default-encoding="UTF-8"를,하지만이 시도 할 때 파이썬은 CLI와 모두이 오류가 또는 왜 그것이 CLI에서 작동하고 파이썬을 통해 호출하지 않을까요?

답변

2

이 시도 :

sass --default-encoding UTF-8 
0

SASS의 문서 say on this :

Encodings

When running on Ruby 1.9 and later, Sass is aware of the character encoding of documents. Sass follows the CSS spec to determine the encoding of a stylesheet, and falls back to the Ruby string encoding. This means that it first checks the Unicode byte order mark, then the @charset declaration, then the Ruby string encoding. If none of these are set, it will assume the document is in UTF-8.

To explicitly specify the encoding of your stylesheet, use a @charset declaration just like in CSS. <...>

그래서, 당신은 여기에 옵션의 전체 무리가있다.

"Ruby 문자열 인코딩"부분은 Set UTF-8 as default for Ruby 1.9.3을 참조하십시오.