本人打算在windows 7下,使用octopress搭建部落格。
有一個問題不得其解:
cmd終端,使用chcp 65001, rake generate編譯沒有問題。
但是,用git bash終端,已經設定了變數如下:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LESSCHARSET=utf-8
rake generate產生下面問題:
octopress/plugins/backtick_code_block.rb:13:in
gsub': incompat ible character encodings: UTF-8 and GBK (Encoding::CompatibilityError) from octopress/plugins/backtick_code_block.rb:13:in
re nder_code_block'
from octopress/plugins/octopress_filters.rb:12:inpre_ filter' from octopress/plugins/octopress_filters.rb:28:in
pre_ render'
from octopress/plugins/post_filters.rb:112:inblock in pre_render' from octopress/plugins/post_filters.rb:111:in
each'
from octopress/plugins/post_filters.rb:111:inpre_rend er' from octopress/plugins/post_filters.rb:166:in
do_layou t'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-0.12.0/lib/jekyll/po
st.rb:195:inrender' from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-0.12.0/lib/jekyll/si te.rb:200:in
block in render'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-0.12.0/lib/jekyll/si
te.rb:199:ineach' from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-0.12.0/lib/jekyll/si te.rb:199:in
render'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-0.12.0/lib/jekyll/si
te.rb:41:inprocess' from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/jekyll-0.12.0/bin/jekyll:26 4:in
'
from c:/Ruby200-x64/bin/jekyll:23:inload' from c:/Ruby200-x64/bin/jekyll:23:in
'
有誰可以幫忙分析一下,是怎麼回事,git bash有等價cmd終端的chcp類似指令嗎?
補充說明:
在目前git bash終端下,輸入中文是沒有問題的;同時中文問題只是發生在程式碼高亮模組裡,其他位置的中文是沒有這個情況的,如果不需要程式碼高亮,也是沒有這個問題。
PHP中文网2017-04-24 09:14:15
由於git bash終端基本上等同於cmd終端。
參考此文 http://www.soimort.org/posts/118/ 對windows終端有詳細的說明。
由於我想在git bash上面操作,git bash提供了大部分linux習慣的指令。
寫了一個腳本,
#! /bin/sh
/c/Windows/System32/chcp.com 65001
rake generate
/c/Windows/System32/chcp.com 936
編譯時暫時改為65001模式,編譯後再恢復回目前的936模式。
@依雲, 非常感謝,很熱情,及時而且專業的support! ! !