#! /usr/bin/env python3## Fixes encoding of the project files to add UTF-8 BOM.## Visual Studio insists on having the BOM in project files, and will# restore it on first edit. This script will go through the relevant# files and ensure the BOM is included, which should prevent too many# irrelevant changesets.#frompathlibimportPath__author__="Steve Dower <steve.dower@python.org>"__version__="1.0.0.0"deffix(p):withopen(p,'r',encoding='utf-8-sig')asf:data=f.read()withopen(p,'w',encoding='utf-8-sig')asf:f.write(data)ROOT_DIR=Path(__file__).resolve().parentif__name__=='__main__':count=0print('Fixing:')forfinROOT_DIR.glob('*.vcxproj'):print(f' - {f.name}')fix(f)count+=1forfinROOT_DIR.glob('*.vcxproj.filters'):print(f' - {f.name}')fix(f)count+=1print()print(f'Fixed {count} files')