sublime && c++ 配置问题
2013-06-04 00:11
218 查看
配置完gcc和sublime后,编译C++程序不显示结果
Ctrl+` 显示错误信息为
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 3: ordinal not in range(128)
这个问题的起因是配置文件目录下Packages\Default目录下的exec.py在编辑环境变量,但是环境变量中的字符集确少了ascii字符集
找到45行
for k, v in proc_env.iteritems():
proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())
编码错误问题,打开C:\Users\stargazer\AppData\Roaming\Sublime Text 2\Packages\Default 里面的exec.py文件编辑
解决方法有:
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
然后你在尝试对pyhon或是其他程序的编译,就会发现切正常了!
要进行数据输入的话,重新配置builder文件
代码如下
其中 cb_console_runner.exe 需要单独下载,并放在英文目录下,设置环境变量。
Ctrl+` 显示错误信息为
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 3: ordinal not in range(128)
这个问题的起因是配置文件目录下Packages\Default目录下的exec.py在编辑环境变量,但是环境变量中的字符集确少了ascii字符集
找到45行
for k, v in proc_env.iteritems():
proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())
编码错误问题,打开C:\Users\stargazer\AppData\Roaming\Sublime Text 2\Packages\Default 里面的exec.py文件编辑
解决方法有:
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
然后你在尝试对pyhon或是其他程序的编译,就会发现切正常了!
要进行数据输入的话,重新配置builder文件
代码如下
{ "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}","-Wall" ,"&&","start","C:/cb_console_runner.exe","${file_path}/${file_base_name}"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++", "shell": true, "encoding": "cp936", "variants": [ { "name": "Run", "cmd": ["start","C:/cb_console_runner.exe","${file_path}/${file_base_name}"] } ] }
其中 cb_console_runner.exe 需要单独下载,并放在英文目录下,设置环境变量。
{ "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}","-Wall" ,"&&","start","C:/cb_console_runner.exe","${file_path}/${file_base_name}"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++", "shell": true, "encoding": "cp936", "variants": [ { "name": "Run", "cmd": ["start","C:/cb_console_runner.exe","${file_path}/${file_base_name}"] } ] }
相关文章推荐
- 【C++&&OpenCV】解决cvLoadImage等函数不能进行单步调试的OpenCV配置问题
- 总结sublime c++编译环境搭建 | 中文乱码问题解决方案 |sidebar配置 |sublime最佳插件列表|最佳主题方案
- Emacs中c/c++环境配置时出现问题 Debugger entered--Lisp error: (error "not support.")
- Xcode 4.2 Can't read stdin: End of file found 配置svn问题
- 关于"xampp中mysql中配置问题:Unknown initial character set index '48' received from server错误解决方法"
- c++ 头文件包含问题-include&class
- 配置OpenCV产生flann\logger.h(66): error C4996: 'fopen': This function or variable may be unsafe问题
- linux单独安装oracle客户端及exp/imp工具配置&proc c_c++
- C++读写配置文件"*.ini
- OpenCV2.0在VS2010配置中出现问题的解决方法 VS2010 C++中出现常见问题:back_inserter
- C++之父元旦专访(8+13个问题,关于C++的学习&使用和未来)
- c strlen & C++ strlen,求长度问题,很容易犯错。
- IIS服务器下ASP程序的配置问题-URL Rewriting && Multiple Site ID
- "c++ list", c++链表遇上的问题
- MATLAB 安装 问题 配置Microsoft Visual C++ 2008 Redistributable 的解决方法
- Qt creator的"纯c/c++项目"输出中文乱码的问题
- 关于Struts2.1.6中配置 constant name="struts.devMode" value="true" 在tomcat启动时报错的问题 .
- 工作问题积累(十一)如何解决"应用程序无法启动,因为应用程序的并行配置不正确"问题
- Dev_c++下解决编译winsock和pthread 的链接问题C++&STL
- Matlab2017b配置C++/C/Fortan编译器的问题(已解决)