import os root_dir = '.' extensions = ('.uvue', '.uts', '.vue', '.json', '.js', '.ts', '.scss', '.md', '.txt', '.ps1', '.bat', '.sh') print(f"Checking every text file in {os.path.abspath(root_dir)} recursively...") found_count = 0 for root, dirs, files in os.walk(root_dir): if any(skip in root for skip in ['.git', 'node_modules', 'unpackage']): continue for file in files: if file.lower().endswith(extensions): path = os.path.join(root, file) try: with open(path, 'rb') as f: data = f.read() # Try UTF-8 try: data.decode('utf-8') # If success, skip continue except UnicodeDecodeError: # Non-UTF8! try: data.decode('gbk') enc = 'GBK' except: enc = 'Other non-UTF8' print(f"{enc:<20} | {os.path.abspath(path)}") found_count += 1 except Exception as e: pass if found_count == 0: print("All scanned files are valid UTF-8.") else: print(f"\nFound {found_count} non-UTF-8 files.")