#!/usr/bin/env python3
"""Fix unicode characters in doc3 script"""
import sys

filepath = '/root/projects/jg/pgs15-scanner-projecten/PhoenixMetals_20260519/working/doc3_veilig_werken_d2.py'

with open(filepath, encoding='utf-8') as f:
    content = f.read()

replacements = {
    '\u2082': '2',
    '\u2083': '3',
    '\u2084': '4',
    '\u2085': '5',
    '\u2086': '6',
    '\u2088': '8',
    '\u2089': '9',
    '\u2080': '0',
    '\u00b0': 'deg',
    '\u00b2': '2',
    '\u00b3': '3',
    '\u2013': '-',
    '\u2014': '-',
    '\u2018': "'",
    '\u2019': "'",
    '\u201c': '"',
    '\u201d': '"',
    '\u2026': '...',
    '\u2022': '-',
    '\u00a7': 'sectie',
}

for old, new in replacements.items():
    content = content.replace(old, new)

with open(filepath, 'w', encoding='utf-8') as f:
    f.write(content)

# Verify it compiles
try:
    compile(content, filepath, 'exec')
    print("OK - file compiles successfully")
except SyntaxError as e:
    print(f"STILL BROKEN at line {e.lineno}: {e.msg}")
    print(f"Text: {e.text}")
