Skip to content

Commit 4486a09

Browse files
authored
Fixes encodings in vcxproj files and adds script to automatically do it. (#1631)
1 parent 78e25ab commit 4486a09

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

PCbuild/_overlapped.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">

PCbuild/fix_encoding.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#! /usr/bin/env python3
2+
#
3+
# Fixes encoding of the project files to add UTF-8 BOM.
4+
#
5+
# Visual Studio insists on having the BOM in project files, and will
6+
# restore it on first edit. This script will go through the relevant
7+
# files and ensure the BOM is included, which should prevent too many
8+
# irrelevant changesets.
9+
#
10+
11+
from pathlib import Path
12+
13+
__author__ = "Steve Dower <[email protected]>"
14+
__version__ = "1.0.0.0"
15+
16+
def fix(p):
17+
with open(p, 'r', encoding='utf-8-sig') as f:
18+
data = f.read()
19+
with open(p, 'w', encoding='utf-8-sig') as f:
20+
f.write(data)
21+
22+
ROOT_DIR = Path(__file__).resolve().parent
23+
24+
if __name__ == '__main__':
25+
count = 0
26+
print('Fixing:')
27+
for f in ROOT_DIR.glob('*.vcxproj'):
28+
print(f' - {f.name}')
29+
fix(f)
30+
count += 1
31+
for f in ROOT_DIR.glob('*.vcxproj.filters'):
32+
print(f' - {f.name}')
33+
fix(f)
34+
count += 1
35+
print()
36+
print(f'Fixed {count} files')

0 commit comments

Comments
 (0)