import os

file_path = r"c:\Users\amine\Desktop\TRAKYO\lang\fr\business.php"

with open(file_path, "r", encoding="utf-8") as f:
    content = f.read()

# Let's try converting from latin-1 to utf-8
try:
    fixed_content = content.encode('latin-1').decode('utf-8')
    with open(file_path, "w", encoding="utf-8") as f:
        f.write(fixed_content)
    print("Successfully fixed business.php using latin-1 encoding to utf-8 decoding!")
except Exception as e:
    print("Error during direct encoding conversion:", e)
    # Let's find where it fails
    for i, char in enumerate(content):
        try:
            char.encode('latin-1')
        except Exception as char_err:
            print(f"Character at index {i} ('{char}') cannot be encoded in latin-1: {char_err}")
            # print surrounding text
            start = max(0, i - 20)
            end = min(len(content), i + 20)
            print("Context:", repr(content[start:end]))
            break
