import os root_dir = r'd:\骅锋\mall\pages\mall\admin' extensions = ('.uvue', '.uts', '.vue', '.json', '.js', '.ts', '.scss', '.md', '.txt', '.ps1', '.bat', '.sh') non_utf8_files = [] for root, dirs, files in os.walk(root_dir): for file in files: if file.lower().endswith(extensions): file_path = os.path.join(root, file) try: with open(file_path, 'rb') as f: data = f.read() # Check utf-8 try: data.decode('utf-8') except UnicodeDecodeError: # Non-UTF8 # Try GBK try: data.decode('gbk') enc = 'GBK' except: enc = 'Unknown' non_utf8_files.append((file_path, enc)) except Exception as e: print(f"Error reading {file_path}: {e}") if not non_utf8_files: print("All files in pages/mall/admin are valid UTF-8.") else: print(f"Found {len(non_utf8_files)} non-UTF8 files in pages/mall/admin:") for path, enc in non_utf8_files: print(f"{enc}: {path}")