度娘了好久都没有找到Mac os解决Sublime Text2的中文乱码问题的教程,
于是自己琢磨了半天,研究了一下并成功在Mac os下直接用sublime Text2开含中文的文件。
(再也不用每次开个dos平台下的东西还要去XCode转个码什么的了。。。)
步骤如下:
0. 打开Sublime text
1. Control+‘~’打开控制台,
输入命令按照Sublime package control,按照这个官网来(https://sublime.wbond.net/installation#st2)
如果是Sublime text3,则如下:
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
如果是Sublime text2,则如下:
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
2. 回车安装完成,重启sublime text2 / 3
3. Command+shift+p,打开刚才安装的package control 命令行控件
4. 输入Install Package
5. 等它载入完包目录后,输入“ConvertToUTF8”或“GBK Encoding Support”,然后回车安装
6. 安装完重启Sublime text2,就可以看见美丽的汉字出现了!
Mac os下解决Sublime Text2或3中文乱码问题
原文地址:http://blog.csdn.net/love_fdu_llp/article/details/41961055