Syntax error: Invalid GBK character error occurs when sass is compiled in ruby,
The ruby environment is used for sass file compilation. Interface-based koala tools and command line modes cannot be used, which is really annoying.
It is easy to see that Chinese comments cannot be compiled or garbled, and the solution after several days is finally solved.
The odd thing about this problem is that there is no problem in the xp environment, but it only appears in the Windows 7 environment.
The following error occurs during sass Compilation:
Syntax error: Invalid GBK character "\xE5" on line 8 of E:\work\sass\sass\_big_box.scss from line 16 of E:\work\sass\sass\main.scss Use --trace for backtrace.
Or
Syntax error: Invalid GBK character "\xE5" on line 2 of E:\work\sass\sass\main.scss Use --trace for backtrace.
Solution:
1. koala visual compilation tool,
Find the engine. rb file under the sass-3.3.7 module in the installation directory, for example, the following path:
C: \ Program Files (x86) \ Koala \ rubygems \ gems \ sass-3.3.7 \ lib \ sass
Add a line of code to the engine. rb file.
Encoding.default_external = Encoding.find('utf-8')
Put it after all require XXXX.
2. Similarly, the command line tool
Find the ruby installation directory, which also contains the sass module, as shown in the following path:
C: \ Ruby \ lib \ ruby \ gems \ 1.9.1 \ gems \ sass-3.3.14 \ lib \ sass
In this file, add a line of code (same method 1) to engine. rb)
Encoding.default_external = Encoding.find('utf-8')
Put it after all require XXXX.
Thanks https://github.com/imathis/octopress/issues/232Mattn provides a solution, which is very suitable here.