Fix UnicodeEncodeError pe Windows pentru caractere românești

Problema:
- Logging eșua cu UnicodeEncodeError când scria caractere românești (ă, î, ș)
- Windows cmd.exe folosește cp1252 implicit, nu UTF-8

Soluție:
- Forțare encoding UTF-8 pentru stdout și stderr
- Folosește io.TextIOWrapper cu encoding='utf-8'
- errors='replace' pentru caractere care nu pot fi encodate

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-06 21:31:55 +02:00
parent 821c1a8e01
commit c2ca401a26

View File

@@ -5,6 +5,7 @@ Telegram Trigger Bot - Declanșează BTGO Scraper prin comandă Telegram
import os import os
import sys import sys
import io
import subprocess import subprocess
import logging import logging
import json import json
@@ -25,6 +26,10 @@ CHAT_ID = os.getenv('TELEGRAM_CHAT_ID')
POLL_TIMEOUT = int(os.getenv('TELEGRAM_POLL_TIMEOUT', 60)) # Default 60 secunde POLL_TIMEOUT = int(os.getenv('TELEGRAM_POLL_TIMEOUT', 60)) # Default 60 secunde
# Logging - force stdout instead of stderr (for Windows service logging) # Logging - force stdout instead of stderr (for Windows service logging)
# Set UTF-8 encoding for stdout to support Romanian characters
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
logging.basicConfig( logging.basicConfig(
level=logging.INFO, level=logging.INFO,
format='[%(asctime)s] [%(levelname)s] %(message)s', format='[%(asctime)s] [%(levelname)s] %(message)s',