Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
原文链接
http://blog.csdn.net/bbdxf/article/details/25594703
[Decode error - output not utf-8]或者[Decode error - output not gbk]
错误信息意思就是脚本输出的信息不是某种指定编码.
指定的编码一般在XX.sublime-build里,比如ruby.sublime-build的内容为:
{
"shell_cmd": "ruby \"$file\"",
"file_regex": "(\\w:...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby",
"encoding": "utf-8",
}
我们可以通过修改ruby.sublime-build来修改输出文字信息的编码.
2.将ruby.sublime-build复制到sublime text的Data\Packages\User\目录
以上这种修改有局限,比如我有时候输出的是utf-8,有时候输出的是gbk,这时候就不行了.
1.在sublime text的安装目录下的Packages\目录下找到Default.sublime-package,将这个复制出来,将后缀改名为zip.
2.打开exec.py.找到类ExecCommand的append_data函数,在以下位置添加代码
def append_data(self, proc, data):
if proc != self.proc:
# a second call to exec has been made before the first one
# finished, ignore it instead of intermingling the output.
if proc:
proc.kill()
return #add start
is_decode_ok = True;
try:
str = data.decode(self.encoding)
except:
is_decode_ok = False
if is_decode_ok==False:
try:
str = data.decode("gbk")
except:
str = "[Decode error - output not " + self.encoding + " and gbk]\n"
proc = None # Normalize newlines, Sublime Text always uses a single \n separator
# in memory.
str = str.replace('\r\n', '\n').replace('\r', '\n') self.output_view.run_command('append', {'characters': str, 'force': True, 'scroll_to_end': True})
其原理就是在解码输出文字编码出错时再使用gbk试试,相当于utf-8和gbk两种编码都试试,这样可以解决编码错误的问题.
Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法的更多相关文章
- Sublime Text 2报“Decode error - output not utf-8”错误的解决办法
[Decode error - output not utf-8] [Decode error - output not utf-8] 应该怎么办? 这是因为python配置的编译环境的编码不 ...
- python+sublime text2中文乱码[Decode error - output not utf-8]
转自: http://blog.sina.com.cn/s/blog_765abd7b0101dtbw.html 学习,记录一下.中文编码真的挺麻烦.抽空把自己的sb3的配置写一些. 该问题让我纠结了 ...
- 使用sublime text 2 版本至今我所遇到的问题及解决方法
1.汉化:下载汉化包 .打开程序Preference下的浏览包文件夹.将解压的程序包粘贴进包文件夹2.破解:标题栏上面有带(unregistered)表示还没有注册: 打开HELP→Enter lic ...
- Sublime Text 执行后只有运行时间,没有执行结果!解决方法!
问题:build完python代码,只输出:[Finished in 0.2s] 分析:操作回忆:开始是可以看到运行结果的,后来在Tools>>Build with 选择了"Sy ...
- Sublime Text3 运行Python 出现Error:Decode error - output not utf-8
问题描述: Sublime Text 3 在build Python时,如果python源代码输出有中文,例如"print('中文')",Sublime Text 会报 [Deco ...
- Sublime Text: [Decode error - output not utf-8]
今天编译Python时, 输出窗口信息出现: [Decode error - output not utf-8][Decode error - output not utf-8] 发现是print ...
- sublime ruby [Decode error - output not utf-8] 错误
今天用sublime3 写ruby,然后最简单的 pust "hello" 都出不来, ctrl + b的时候报错.注:win7下 [Decode error - output n ...
- 配置python学习环境遇到的问题:[Decode error - output not utf-8]
因为前阵子学习monkeyrunner的时候,碰到了很多关于.py的脚本,其实我是一知半解的,也没打算去学习一下.将就着看看吧,后来无意中看到自动化测试工程师都要求会脚本语言的时候,刺激了我,想了想, ...
- 阿里云服务器出现Warning: Cannot modify header information - headers already sent by (output started at 问题的解决方法
阿里云服务器出现Warning: Cannot modify header information - headers already sent by (output started at 问题的解决 ...
随机推荐
- oracle DML语句
DML语句 1. 插入数据 创建一个新表 create table new_cust as select * from customers --使用insert语句添加行 /* 确定要插入的行所在的 ...
- jquery调用iframe里面的方法
$(window.parent.document).contents().find("#iframename")[0].contentWindow.iframefunction() ...
- DataGridView操作小记(1)
1.获取总列数 int Column_num = DataGridView1.ColumnCount; 2.获取总行数 int Column_num = DataGridView1.RowCount; ...
- IAR软件的使用
STM32标准外设库下载 官网下载链接(需要ST账号登陆): http://www.st.com/content/st_com/en/products/embedded-software/mcus-e ...
- 44_redux_comment应用_redux版本_同步功能
项目结构: components里面的东西没变,将app.jsx移动至containers中 /* * 包含所有action的type名称常量 * */ //添加评论 export const ADD ...
- activiti官网实例项目activiti-explorer之扩展多选框回显功能
相关参考链接:https://blog.csdn.net/murongxuesheng/article/details/76147380 回显:确认选中属性ng-model,循环属性ng-repeat ...
- springboot配置swagger
1,添加配置类 @Configuration @EnableSwagger2 @Profile({"default", "dev-online", " ...
- 解决laravel使用QQ邮箱发邮件失败
在 laravel 中使用 QQ 发送邮件的时候莫名其妙的出现了如下错误:Connection could not be established with host smtp.exmail.qq.co ...
- Druid中配置双数据库
配置如下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://w ...
- SQLServer与MySQL约束/索引命名的一些差异总结
约束是数据库完整性的保证,主要分为:主键/外键/唯一键/默认值/check等类别,约束是一个逻辑概念,表示数据的某些特性(不能为空,唯一,必须满足某些条件等等),索引是一个逻辑与物理概念的结合,逻辑上 ...