Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
来源:互联网 发布:犀牛设计软件视频教程 编辑:程序博客网 时间:2024/04/28 10:56
[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",
- }
其中encoding就是指定的编码,ruby.sublime-build可以在Sublime Text 3\Packages\Ruby.sublime-package里找到.
我们可以通过修改ruby.sublime-build来修改输出文字信息的编码.
1. 将ruby.sublime-build文件从Ruby.sublime-package里复制出来,(注意:Ruby.sublime-package是一个zip压缩文件,只要将其后缀名改为zip即可打开这个压缩文件)
2.将ruby.sublime-build复制到sublime text的Data\Packages\User\目录
3. 打开此文件,将此文件中的"encoding": "utf-8"修改为"encoding": "gbk"
以上这种修改有局限,比如我有时候输出的是utf-8,有时候输出的是gbk,这时候就不行了.
以下方法可以解决这个局限.
1.在sublime text的安装目录下的Packages\目录下找到Default.sublime-package,将这个复制出来,将后缀改名为zip.
是的,它就是个zip文件,解压缩它,然后将其中的exec.py文件放到sublime text的Data\Packages\User\目录下.
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两种编码都试试,这样可以解决编码错误的问题.
作者:hgyxbll,原文链接:http://shashanzhao.com/archives/976.html
- Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
- Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
- Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
- Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
- Sublime text 3 [Decode error - output not utf-8]或者[Decode error - output not gbk] 解决方法
- Sublime Text 2/3 [Decode error - output not utf-8]
- Sublime Text: [Decode error - output not utf-8]
- Sublime Text [Decode error - output not utf-8]
- Sublime Text [Decode error - output not utf-8]
- SUBLIME TEXT [DECODE ERROR - OUTPUT NOT UTF-8] 解决方案
- Python Sublime Text: [Decode error - output not utf-8]
- sublime :[Decode error - output not utf-8]
- Sublime Text 2报“Decode error - output not utf-8”错误的解决办法
- Sublime Text 2报“Decode error - output not utf-8”错误的解决办法
- sublime sublime text3 提示[decode error - output not utf-8]
- sublime text编译时提示错误[Decode error - output not utf-8] compilation terminated
- 【Sublime Text 3】——Decode error - output not utf-8
- sublime 出现 [Decode error - output not utf-8]
- 《深入理解SPARK:核心思想与源码分析》(第1章)
- hybris trail goal
- python数字图像处理(4):图像数据类型及颜色空间转换
- centos挂载SSD
- Android开发中使用软引用和弱引用
- Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法
- JFinal jetty maven配置jsp支持
- 类 BigDecimal
- Android缓存文件的存放
- 用mysqldump导出压缩文件
- 以高端“产品”提升“市场”竞争力
- 乱码被GZip压缩过的Response进行解压
- deletefile 失败
- cors 跨域详解