restore_utf8.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Run "python restore_utf8.py" to rename *.h.utf8 to *.h.
#
import os
def restore_utf8(dir):
resultfn = ''
for fn in os.listdir(dir):
sfile = os.path.join(dir, fn)
if os.path.isdir(sfile):
resultfn += restore_utf8(sfile)
continue
if fn.endswith('.utf8'):
orgfile = sfile[:-5]
try:
if os.path.exists(orgfile): os.remove(orgfile)
os.rename(sfile, orgfile)
resultfn += fn[:-5] + ' '
except:
print('except for %s' %(fn,))
return resultfn
if __name__=="__main__":
resultfn = restore_utf8(os.path.abspath('.'))
resultfn += restore_utf8(os.path.abspath('../core'))
resultfn += restore_utf8(os.path.abspath('../android'))
if resultfn != '': print('restore files: ' + resultfn)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Run "python utf8togbk.py" to convert source code files to the GBK format on Windows.
#
import os, codecs, sys
reload(sys)
sys.setdefaultencoding('gbk')
def utf8togbk(dir):
resultfn = ''
for fn in os.listdir(dir):
sfile = os.path.join(dir, fn)
if os.path.isdir(sfile):
resultfn += utf8togbk(sfile)
continue
if fn.endswith('.h') or fn.endswith('.cpp'):
if os.path.exists(sfile + '.utf8'):
continue
try:
text = open(sfile,'r',-1,'utf-8').read()
oldtext = text
except UnicodeDecodeError:
continue
except TypeError:
text = open(sfile).read()
oldtext = text
try:
if text[:3] == codecs.BOM_UTF8:
u = text[3:].decode('utf-8')
text = u.encode('gbk')
except UnicodeEncodeError:
continue
except UnicodeDecodeError:
continue
try:
text = text.replace('\r\n','\n')
text = text.replace('\n','\r\n')
if cmp(text, oldtext) != 0:
os.rename(sfile, sfile + '.utf8')
open(sfile, 'wb').write(text)
resultfn += fn + ' '
st = os.stat(sfile + '.utf8')
os.utime(sfile, (st.st_atime, st.st_mtime))
except:
print('except for %s' %(fn,))
return resultfn
if __name__=="__main__":
resultfn = utf8togbk(os.path.abspath('.'))
resultfn += utf8togbk(os.path.abspath('../core'))
resultfn += utf8togbk(os.path.abspath('../android'))
if resultfn != '': print('utf8->gbk: ' + resultfn)
分享到:
相关推荐
[量产部落]Restore_v3.26.0.0
这是一个注册表文件,如果你的系统是win10系统,想使用win7使用时的看图工具,那么你直接管理员运行此注册表,打开一个图片就会跳出新的打开方式,选择你要用的方式就可以了!!
U盘写保护格式化工具(U盘点击修复、格式化都是格式化,注意数据安全性),个人实践可用,不需要积分,如涉及保密或知识产品,请联系我删除
I959_EFS_Backup_Restore_WIN
root工具 Root_with_Restore_by_Bin4ry_v25
veeam_backup_9_5_u4_backup_restore_sql_pg_IT软件公司技术售前方案.pdf
restore_vhd.img,制作快速恢复vhd系统很方便,我找了很久才找到的。
delphi的驱动 功能是恢复ssdt的地址.
【12c】12c RMAN新特性之通过网络远程恢复数据库(RESTORE_Recover from Service) new_ITPUB博客.mhtml
支持从裸磁盘、分区、文件中搜索所有IBD page碎片。 1、输入字母a-z :搜索对应的逻辑分区A-Z。此模式请以管理员身份运行。 2、输入数字1-9 :搜索物理磁盘,对应“磁盘管理器”中的磁盘0-9。...
训练模型
直接将ios固件拖向图标即可生成专用固件,用此固件恢复ios设备时将会保留用户数据。方便beta版开发。
Data-Unit_MongoDB_Restore适用于磁盘存储故障、勒索病毒删除、误操作删除等导致的数据库丢失恢复。运行工具后将数据文件拖入本窗口即可。也支持扫描分区和裸磁盘,建议扫描磁盘镜像文件,效果更好。 免费版每个集合...
官方例子,深度学习专用,机器学习专用,代码简单,一看就会(tensorflow save restore model demo)
永恒之塔十全补丁,直接点击安装就可以了,下的朋友谢谢了,赚下积分啦
Android上最快的数据备份工具! 您可以将应用程序和联系人,短信和通话记录,书签和日历备份到SD卡/ Gmail。您再也不会丢失数据! 这是Super Backup Dark Theme的广告免费版本即将推出!!! ...如果您的手机具有内置...
生成模拟的针叶图像,利用PSF进行温度恢复
this program simply removes the line numbers files.this is useful for pages downloaded web which contains ... so for make the code work we have to remove line numbers. and this program does this work.
恢复SSDT的代码,用来干什么自己想吧 主程序在vc下编译通过,驱动用winddk编译
Delphi sources codes