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 问题的解决 ...
随机推荐
- 移动端常用UI框架
作为一个前端人员来说,总结几款相对来说不错的用于移动端开发的UI框架是非常必要的,以下几种移动端UI框架就能基本满足工作中开发需要,根据项目需求,选用合适的框架搭建项目,更能容易提高开发效率. 一.M ...
- 关于单元测试时加载spring-context.xml文件的问题
在进行web开发的时候,通常我们都会使用Spring框架,使用spring容器管理java bean. 而spring的配置文件有时候放在classpath下面,有时候放在WEB-INF下面. 一般在 ...
- linux远程ssh一键设置服务器时间
cmd="sudo date -s \"$1\""; ssh mrdTomcat@*.*.*.* "$cmd" 是不是遇到过很多问题 ssh ...
- rsync 文件同步和备份
rsync 是同步文件的利器,一般用于多个机器之间的文件同步与备份,同时也支持在本地的不同目录之间互相同步文件.在这种场景下,rsync 远比 cp 命令和 ftp 命令更加合适,它只会同步需要更新的 ...
- 每日算法之递推排序(P1866 编号)
兔子也是数字控:每个兔子都有自己喜欢的数字区间,找出能让所有兔子都满意的组合. 将所有兔子喜欢的序号按从小到大排序,此时如果小序号的兔子选择了一个数字,则之后的兔子只要排除排在它之前的兔子数(由于已经 ...
- Hibernate 中出现 users is not mapped 问题
Hibernate 中出现 users is not mapped 问题: 解答:HQL语句中表名应该是ORM映射的类名,所以应该改成: (如果是用注解生成实体类,那就是注解的那个类)String ...
- mysql学习一 常用语句
操作系统为windows 1 启动关闭mysql服务 //windows mysqld --console //开启mysql服务 mysqladmin -uroot shutdown //关闭my ...
- windows安装tf
https://www.cnblogs.com/lvsling/p/8672404.html
- 一条分页的SQL语句
1.概述 在网页中如果显示的数据太多就会占据过多的页面,而且显示速度也会很慢.为了控制每次在页面上显示数据的数量,就可以利用分页来显示数据. 2.技术要点 在SQL Server中要实现SQL分页,需 ...
- ElasticSearch 使用问题
1.设置空格分词器 PUT /my_index/my_type/_mapping { "my_type": { "_all": { "analyzer ...