-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_unicode.py
More file actions
27 lines (23 loc) · 854 Bytes
/
Copy pathfix_unicode.py
File metadata and controls
27 lines (23 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
with open('src/report_generator.py', 'r', encoding='utf-8') as f:
content = f.read()
replacements = {
'\u2014': '-', # em dash —
'\u2013': '-', # en dash –
'\u2018': "'", # left single quote '
'\u2019': "'", # right single quote '
'\u201c': '"', # left double quote "
'\u201d': '"', # right double quote "
'\u2026': '...', # ellipsis …
'\u2022': '-', # bullet •
}
count = 0
for char, replacement in replacements.items():
occurrences = content.count(char)
if occurrences:
print(f"Replacing {occurrences}x U+{ord(char):04X} ({char}) -> '{replacement}'")
content = content.replace(char, replacement)
count += occurrences
with open('src/report_generator.py', 'w', encoding='utf-8') as f:
f.write(content)
print(f"\nTotal replacements: {count}")
print("Done.")