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

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

  •  
  •   justend Jan 24, 2012 11501 views
    This topic created in 5227 days ago, the information mentioned may be changed or developed.
    只要在jekyll或octopress中加入中文字符,就无法通过rake generate. 在网上搜索发现可以通过加环境变量的方式解决,加了LC_ALL=zh_CN.UTF-8和LANG=zh_CN.UTF-8后,还是不行(centos,mac,windows都试过了),不知大家有没有遇到同样的问题,怎么解决的


    谢谢
    24 replies    1970-01-01 08:00:00 +08:00
    sparanoid
        1
    sparanoid  
       Jan 24, 2012
    报错内容?我只用 Jekyll,没出现过这个问题
    justend
        2
    justend  
    OP
       Jan 24, 2012
    @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  
       Jan 24, 2012
    "invalid byte sequence in GBK" 你应该检查程序为什么认为你的内容是 GBK,比如是不是某个配置的问题。
    justend
        4
    justend  
    OP
       Jan 24, 2012
    没有配置过任何东西,git clone最新的代码后,只是扔个post文件,然后在文件中写几个中文就出这问题了
    tomliu
        5
    tomliu  
       Jan 24, 2012
    @justend 上次我遇到这个问题是_config.yml 里某个某个冒号后面少了空格。
    justend
        6
    justend  
    OP
       Jan 24, 2012
    @tomliu

    谢谢,不是这个问题,新clone的源码,这个文件都没改过
    jjgod
        7
    jjgod  
       Jan 24, 2012
    @justend: 那你是用什么编码写的?
    justend
        8
    justend  
    OP
       Jan 24, 2012
    @jjgod

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

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

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

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

    再有问题我也不知道了
    sampeng
        20
    sampeng  
       May 4, 2012
    windows的悲剧。。。。这种玩意就是给类linux系统用的。。。windows很憋屈的
    Banana_Co
        21
    Banana_Co  
       Nov 5, 2012
    以上 @amycs , :encoding => "utf-8" 中的 "utf-8" 应该为 'utf-8' 单引号,亲测通过。
    AlfredZhao
        22
    AlfredZhao  
       Nov 9, 2012
    看来还是用Mac写吧,在公司就老老实实写代码,写博客也算私活,哈哈哈
    mytharcher
        23
    mytharcher  
       Nov 9, 2012
    可以用<prose.io>写
    gdm
        24
    gdm  
       Jan 8, 2014
    jekyll 的话,本地根本不用装啊,装个 git 就行了, push 到 github 他会自动编译
    About     Help     Advertise     Blog     API     FAQ     Solana     902 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 72ms UTC 22:23 PVG 06:23 LAX 15:23 JFK 18:23
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86