From fcad3df14441e92782b6092915bb89ae6a2697e7 Mon Sep 17 00:00:00 2001 From: helei Date: Mon, 10 Aug 2026 21:18:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E4=B8=B4=E6=97=B6=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- V1.5/to_gbk.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 V1.5/to_gbk.py diff --git a/V1.5/to_gbk.py b/V1.5/to_gbk.py deleted file mode 100644 index 66dfe05..0000000 --- a/V1.5/to_gbk.py +++ /dev/null @@ -1,34 +0,0 @@ -import os, sys, io -sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') - -ROOTS = [ - 'V1.5/STM32F103_App1/HardWare', - 'V1.5/STM32F103_App1/Src', - 'V1.5/STM32F103_App1/Inc', - 'V1.5/STM32F103_App1/m_app', - 'V1.5/STM32F103_BootLoader/HardWare', - 'V1.5/STM32F103_BootLoader/Src', - 'V1.5/STM32F103_BootLoader/m_app', -] - -for root in ROOTS: - for dirpath, _, files in os.walk(root): - for fn in files: - if not fn.endswith(('.c', '.h')): - continue - p = os.path.join(dirpath, fn) - raw = open(p, 'rb').read() - try: - text = raw.decode('utf-8') - except UnicodeDecodeError: - print('SKIP (not utf-8):', p) - continue - try: - out = text.encode('gbk') - warn = '' - except UnicodeEncodeError as e: - out = text.encode('gbk', errors='replace') - warn = ' [WARN 有字符被替换: %r]' % text[e.start:e.end] - if out != raw: - open(p, 'wb').write(out) - print('converted:', p, warn)