Yhzhtk's Blog

(热爱技术,高效Code)     归档  标签  源码  关于 


Jekyll 在 Windows 下面中文编码问题解决方案

2013-06-04    jekyll  编码 


在jekyll-bootstrap的index.md中输入中文即会出现"invalid byte sequence in GBK"的错误. 出错代码如下:
C:\Documents and Settings\yhzhtk\blog>jekyll build .
Configuration file: C:/Documents and Settings/yhzhtk/blog/_config.yml
            Source: C:/Documents and Settings/yhzhtk/blog
       Destination: C:/Documents and Settings/yhzhtk/blog/_site
      Generating... Error reading file C:/Documents and Settings/yhzhtk/blog/_posts/2013-5-30-day.html: invalid byte sequ
ence in GBK
[31m  Liquid Exception: invalid byte sequence in GBK in 2013-5-30-day.html[0m
C:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/template.rb:141:in `split'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/template.rb:141:in `tokenize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/liquid-2.5.0/lib/liquid/template.rb:58:in `parse'
解决方案为: 将E:\Jekyll\Ruby193\lib\ruby\gems\1.9.1\gems\jekyll-0.12.1\lib\jekyll\convertible.rb文件的28行
self.content = File.read(File.join(base, name))
改为
self.content = File.read(File.join(base, name), :encoding => "utf-8")




Load Disqus comments, wait a moment..

©2013 首页   关于     View me on GitHub Powered by Jekyll & Bootstrap 知识共享许可协议