INNER CODE UNIT · Python
main
KSwordDEV/KSword · KswordHUD/to_u8.py:41
def main():
# 获取当前目录
current_dir = os.getcwd()
print(f"📂 处理目录: {current_dir}")
# 筛选出.h和.cpp文件(不包含子文件夹)
for filename in os.listdir(current_dir):
file_path = os.path.join(current_dir, filename)
# 只处理文件,不处理文件夹
if os.path.isfile(file_path):
# 检查文件后缀
if filename.lower().endswith(('.h', '.cpp')):
convert_to_utf8(file_path)
print("🎉 处理完成")
if __name__ == "__main__":
# 检查是否安装了chardet库