From c2ca401a26220182e0a54f0c40b91149a8b49117 Mon Sep 17 00:00:00 2001 From: Marius Mutu Date: Thu, 6 Nov 2025 21:31:55 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20UnicodeEncodeError=20pe=20Windows=20pentr?= =?UTF-8?q?u=20caractere=20rom=C3=A2ne=C8=99ti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- telegram_trigger_bot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/telegram_trigger_bot.py b/telegram_trigger_bot.py index f28c48c..50b8678 100644 --- a/telegram_trigger_bot.py +++ b/telegram_trigger_bot.py @@ -5,6 +5,7 @@ Telegram Trigger Bot - Declanșează BTGO Scraper prin comandă Telegram import os import sys +import io import subprocess import logging 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 # 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( level=logging.INFO, format='[%(asctime)s] [%(levelname)s] %(message)s',