Syntax error: Invalid GBK character error when Sass is compiled in ruby

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.