Files
ableton-mcp-ai/fix_utf8.py

53 lines
2.0 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# Fix UTF-8 double-encoding corruption in sample_selector.py
import os
file_path = '/mnt/c/ProgramData/Ableton/Live 12 Suite/Resources/MIDI Remote Scripts/AbletonMCP_AI/AbletonMCP_AI/MCP_Server/sample_selector.py'
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# Replace corrupted UTF-8 sequences with proper Spanish characters
# These are double-encoded characters: UTF-8 -> Latin1 -> UTF-8
corrupted_to_clean = {
'Selecci': 'Selección',
'gnero': 'género',
'Matching armnico': 'Matching armónico',
'Creaci': 'Creación',
'batera': 'batería',
'automtico': 'automático',
'mltiples': 'múltiples',
'Validaci': 'Validación',
'Penalizaci': 'Penalización',
'Detecci': 'Detección',
'clculos': 'cálculos',
'aceleraci': 'aceleración',
}
for corrupted, clean in corrupted_to_clean.items():
# Find the corrupted pattern and fix it
# Look for patterns like "SelecciÃÆ'ón" -> "Selección"
content = content.replace(corrupted + 'ÃÆ'ó', clean)
content = content.replace(corrupted + 'ÃÆ'é', clean.replace('ón', 'én') if 'ón' in clean else clean.replace('ción', 'ción'))
content = content.replace(corrupted + 'ÃÆ'í', clean.replace('ón', 'ín') if 'ón' in clean else clean)
content = content.replace(corrupted + 'ÃÆ'á', clean.replace('ón', 'án') if 'ón' in clean else clean)
content = content.replace(corrupted + 'ÃÆ'ú', clean.replace('ón', 'ún') if 'ón' in clean else clean)
# Additional direct replacements for common patterns
direct_replacements = [
('ÃÆ'ó', 'ó'),
('ÃÆ'é', 'é'),
('ÃÆ'í', 'í'),
('ÃÆ'á', 'á'),
('ÃÆ'ú', 'ú'),
('ÃÆ'ÃÂ', ''),
]
for wrong, right in direct_replacements:
content = content.replace(wrong, right)
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
print('UTF-8 corruption fixed successfully')