原文链接

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] 完美解决方法的更多相关文章

  1. Sublime Text 2报“Decode error - output not utf-8”错误的解决办法

    [Decode error - output not utf-8] [Decode error - output not utf-8]   应该怎么办?   这是因为python配置的编译环境的编码不 ...

  2. python+sublime text2中文乱码[Decode error - output not utf-8]

    转自: http://blog.sina.com.cn/s/blog_765abd7b0101dtbw.html 学习,记录一下.中文编码真的挺麻烦.抽空把自己的sb3的配置写一些. 该问题让我纠结了 ...

  3. 使用sublime text 2 版本至今我所遇到的问题及解决方法

    1.汉化:下载汉化包 .打开程序Preference下的浏览包文件夹.将解压的程序包粘贴进包文件夹2.破解:标题栏上面有带(unregistered)表示还没有注册: 打开HELP→Enter lic ...

  4. Sublime Text 执行后只有运行时间,没有执行结果!解决方法!

    问题:build完python代码,只输出:[Finished in 0.2s] 分析:操作回忆:开始是可以看到运行结果的,后来在Tools>>Build with 选择了"Sy ...

  5. Sublime Text3 运行Python 出现Error:Decode error - output not utf-8

    问题描述: Sublime Text 3 在build Python时,如果python源代码输出有中文,例如"print('中文')",Sublime Text 会报 [Deco ...

  6. Sublime Text: [Decode error - output not utf-8]

    今天编译Python时, 输出窗口信息出现: [Decode error - output not utf-8][Decode error - output not utf-8]   发现是print ...

  7. sublime ruby [Decode error - output not utf-8] 错误

    今天用sublime3 写ruby,然后最简单的 pust "hello" 都出不来, ctrl + b的时候报错.注:win7下 [Decode error - output n ...

  8. 配置python学习环境遇到的问题:[Decode error - output not utf-8]

    因为前阵子学习monkeyrunner的时候,碰到了很多关于.py的脚本,其实我是一知半解的,也没打算去学习一下.将就着看看吧,后来无意中看到自动化测试工程师都要求会脚本语言的时候,刺激了我,想了想, ...

  9. 阿里云服务器出现Warning: Cannot modify header information - headers already sent by (output started at 问题的解决方法

    阿里云服务器出现Warning: Cannot modify header information - headers already sent by (output started at 问题的解决 ...

随机推荐

  1. 虚拟机Ubuntu18.04——gcc版本的升降

    致读者:这是本人第一篇博客,小试牛刀,希望能在以后的道路中分享出更多实用的技巧和知识,大家一起进步. 操作环境: VMware Workstation 14Pro .64位Ubuntu18.04系统 ...

  2. MYSQL1

    一:对查询就行优化 避免全表查询 1.首先考虑在where及order by 列上建立索引 2.where子句   LIKE  '%abc%' 前置%   引擎放弃使用索引而进行全表扫描 3.wher ...

  3. MFC 读写文件

    写文件: #include<fstream> CStdioFile file; file.Open(_T("parametertable.txt"), CFile::m ...

  4. 把nginx当完全tcp端口转发器

    在nginx.conf里加入 stream {     server {         listen 18443;         proxy_pass 58.xxx.xxx.xxx:8443;   ...

  5. UE4C++定义属性修饰符总结

    1.BlueprintAssignable  暴露该属性来在蓝图中进行赋值,用于绑定多播委托 2.BlueprintCallable  用于从蓝图中调用C++原生函数 3.BlueprintReadO ...

  6. Nagios监控

    1.Nagios监控软件 Nagios是一款开源的免费网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等.在系统或服务状态异常时发出邮件或短信报警 ...

  7. 3G设置linux路由-iptables配置

    1.如何区分iptables的PREROUTING和POSTROUTING链 (引自http://jingyan.baidu.com/article/aa6a2c143d84470d4c19c4cf. ...

  8. 区块链入门(5)Truffle 项目实战,Solidity IDE, 智能合约部署

    在上一张我们学习了Truffle项目的创建,部署等相关内容,今天我们就来实战一下. 今天我们要做3件事: 1) 学习搭建一个Solidity IDE(Remix). 2) 使用这个Solidity I ...

  9. Python设计模式 - UML - 定时图(Timing Diagram)

    简介 定时图也是一种交互图,用来描述对象或实体随时间变化的状态或值,及其相应的时间或期限约束.定时图应用较广,并不局限于软件工程领域. 定时图侧重与时间线相关的值或状态的改变,这些改变可能来自于收到消 ...

  10. vue环境项目启动后因为eslint语法限制报错

    报错太多,截取了一部分. 解决方法找到项目根目录的build 找到webpack.base.conf.js 打开js文件找到下图的位置 再重新启动项目就好了