请教关于Jekyll和octopress的中文问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
justend
V2EX    Jekyll

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

  •  
  •   justend 2012-01-24 20:22:09 +08:00 11107 次点击
    这是一个创建于 5016 天前的主题,其中的信息可能已经有所发展或是发生改变。
    只要在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  
       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
    @jusend 上次我遇到这个问题是_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     Solana     1154 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 17:55 PVG 01:55 LAX 10:55 JFK 13:55
    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