用sublime text 2 编译Ruby 遇到编码的问题(UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 9: ordinal not in range(128))

后端开发   发布日期:2025年08月02日   浏览次数:160
Ctrl+B编译遇到编码错误:UnicodeDecodeError: 'ascii' codec can't decode byte 0xb1 in position 258: ordinal not in range(128) 
 

路径为:C:\Users\您的用户名\AppData\Roaming\Sublime Text 2\Packages\Default\exec.py,打开编辑

找到第44~45行中:

for k, v in proc_env.iteritems():

 proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())

两种修改方案:

1、果断注释掉!

2、对它进行异常处理,避免它出错时停止程序运行就像这样:

  
  for k, v in proc_env.iteritems():
            try:
                proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())
            except UnicodeDecodeError:
                print "Encoding error..."
                print "VARIABLE: ", k, " : ", v

以上就是用sublime text 2 编译Ruby 遇到编码的问题(UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 9: ordinal not in range(128))的详细内容,更多关于用sublime text 2 编译Ruby 遇到编码的问题(UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 9: ordinal not in range(128))的资料请关注九品源码其它相关文章!