V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Jekyll
http://jekyllrb.com/
Jekyll on GitHub
https://github.com/mojombo/jekyll
Jekyll-bootstrap
http://jekyllbootstrap.com/
Octopress
http://octopress.org/
justend
V2EX  ›  Jekyll

请教关于Jekyll和octopress的中文问题

  •  
  •   justend · 2012-01-24 20:22:09 +08:00 · 10469 次点击
    这是一个创建于 4467 天前的主题,其中的信息可能已经有所发展或是发生改变。
    只要在jekyll或octopress中加入中文字符,就无法通过rake generate. 在网上搜索发现可以通过加环境变量的方式解决,加了LC_ALL=zh_CN.UTF-8和LANG=zh_CN.UTF-8后,还是不行(centos,mac,windows都试过了),不知大家有没有遇到同样的问题,怎么解决的


    谢谢
    24 条回复    1970-01-01 08:00:00 +08:00
    sparanoid
        1
    sparanoid  
    MOD
       2012-01-24 20:40:49 +08:00
    报错内容?我只用 Jekyll,没出现过这个问题
    justend
        2
    justend  
    OP
       2012-01-24 20:47:25 +08:00
    @sparanoid 提示信息如下,谢谢回复

    C:\Sites\octopress>bundle exec rake generate
    ## Generating Site with Jekyll
    unchanged sass/screen.scss
    Configuration from C:/Sites/octopress/_config.yml
    Building site: source -> public
    C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/jekyll-0.11.0/lib/jekyll/co
    nvertible.rb:29:in `read_yaml': invalid byte sequence in GBK (ArgumentError)
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/jekyll-0.11.0/
    lib/jekyll/post.rb:39:in `initialize'
    from C:/Sites/octopress/plugins/preview_unpublished.rb:23:in `new'
    from C:/Sites/octopress/plugins/preview_unpublished.rb:23:in `block in r
    ead_posts'
    from C:/Sites/octopress/plugins/preview_unpublished.rb:21:in `each'
    from C:/Sites/octopress/plugins/preview_unpublished.rb:21:in `read_posts
    '
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/jekyll-0.11.0/
    lib/jekyll/site.rb:128:in `read_directories'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/jekyll-0.11.0/
    lib/jekyll/site.rb:98:in `read'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/jekyll-0.11.0/
    lib/jekyll/site.rb:38:in `process'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/jekyll-0.11.0/
    bin/jekyll:250:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/bin/jekyll:19:in `l
    oad'
    from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/bin/jekyll:19:in `<
    main>'
    jjgod
        3
    jjgod  
       2012-01-24 20:59:36 +08:00
    "invalid byte sequence in GBK" 你应该检查程序为什么认为你的内容是 GBK,比如是不是某个配置的问题。
    justend
        4
    justend  
    OP
       2012-01-24 21:07:31 +08:00
    没有配置过任何东西,git clone最新的代码后,只是扔个post文件,然后在文件中写几个中文就出这问题了
    tomliu
        5
    tomliu  
       2012-01-24 21:13:21 +08:00
    @justend 上次我遇到这个问题是_config.yml 里某个某个冒号后面少了空格。
    justend
        6
    justend  
    OP
       2012-01-24 21:21:59 +08:00
    @tomliu

    谢谢,不是这个问题,新clone的源码,这个文件都没改过
    jjgod
        7
    jjgod  
       2012-01-24 21:24:57 +08:00
    @justend: 那你是用什么编码写的?
    justend
        8
    justend  
    OP
       2012-01-24 21:48:49 +08:00
    @jjgod

    utf-8
    dofine
        9
    dofine  
       2012-01-24 21:53:42 +08:00 via Android
    前几天也遇到这个问题,确实是通过在 ~/.bashrc 里 export LC_ALL 和 LANG 搞定的,win7 & mingw
    bcxx
        10
    bcxx  
       2012-01-24 22:06:41 +08:00
    直接用 github page 的 jekyll, 没遇到任何中文问题。 尝试将 _config.yml 编码改为 utf-8?
    justend
        11
    justend  
    OP
       2012-01-25 10:50:58 +08:00
    我用mac上的文本编辑器编辑后写中文一切ok... 暂时就只能用mac写了 -_-

    用windows的编辑器就不行,试过editplus,gedit,notepad plus 等,转换utf-8格式也是不行。
    dofine
        12
    dofine  
       2012-01-25 11:28:23 +08:00 via Android
    @justend 你在windows 上用bash试试?不要用cmd.exe
    ywjno
        13
    ywjno  
       2012-01-25 12:33:31 +08:00
    octopress的话,请把生成的.markdown文件编码给改成”UTF-8无BOM格式”
    amycs
        14
    amycs  
       2012-01-30 15:25:54 +08:00
    我也遇到这个问题。。jekyll 没有用 octopress。。win 下面怎么转换/改配置 都不行 ╮(╯-╰)╭
    amycs
        15
    amycs  
       2012-01-31 14:32:25 +08:00
    我的问题解决了

    self.content = File.read(File.join(base, name), :encoding => "utf-8")

    https://github.com/imathis/octopress/issues/232
    moistrot
        16
    moistrot  
       2012-03-08 09:43:08 +08:00
    windows写就是悲剧。麻烦的很。还是用mac或者linux写起来舒服
    chendeshen
        17
    chendeshen  
       2012-05-04 17:51:29 +08:00
    把全部文件都用utf-8保存,解决所有问题,亲测有效。
    9hills
        18
    9hills  
       2012-05-04 17:59:33 +08:00
    直接用cygwin吧。
    joshualeung
        19
    joshualeung  
       2012-05-04 22:54:58 +08:00
    1,markdown文件如果出现了中文请另存为UTF-8格式且去掉BOM头。
    2, yaml的冒号后要有空格。
    3, 把设置环境变量里的zh_CN改成en_US

    再有问题我也不知道了。
    sampeng
        20
    sampeng  
       2012-05-04 23:07:24 +08:00
    windows的悲剧。。。。这种玩意就是给类linux系统用的。。。windows很憋屈的
    Banana_Co
        21
    Banana_Co  
       2012-11-05 22:15:07 +08:00
    以上 @amycs , :encoding => "utf-8" 中的 "utf-8" 应该为 'utf-8' 单引号,亲测通过。
    AlfredZhao
        22
    AlfredZhao  
       2012-11-09 16:52:23 +08:00
    看来还是用Mac写吧,在公司就老老实实写代码,写博客也算私活,哈哈哈
    mytharcher
        23
    mytharcher  
       2012-11-09 17:22:29 +08:00
    可以用<prose.io>写
    gdm
        24
    gdm  
       2014-01-08 14:57:41 +08:00
    jekyll 的话,本地根本不用装啊,装个 git 就行了, push 到 github 他会自动编译
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5499 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 05:59 · PVG 13:59 · LAX 22:59 · JFK 01:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.