From 752858182de1d99d3fda583a6238797a5d626ee8 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Mon, 26 Jan 2026 23:36:47 +0000 Subject: [PATCH] feat: [US-002] Fix UTF-8 encoding for Windows console MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add UTF-8 encoding setup at the top of backend/main.py to fix 'charmap' codec encoding errors when logging Romanian diacritics (ă, î, ș, ț) on Windows console. Co-Authored-By: Claude Opus 4.5 --- backend/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/main.py b/backend/main.py index 1528851..812fbb3 100644 --- a/backend/main.py +++ b/backend/main.py @@ -3,6 +3,19 @@ ROA2WEB Unified Backend - Single FastAPI Application Consolidates Reports, Data Entry, and Telegram modules into one process """ +# ============================================================================= +# UTF-8 ENCODING FIX FOR WINDOWS CONSOLE +# Must be at the TOP, before any logging or print statements +# Fixes: 'charmap' codec can't encode character errors with Romanian diacritics +# ============================================================================= +import sys +if sys.platform == 'win32': + # Force UTF-8 encoding on Windows console + # This prevents encoding errors when logging Romanian characters (ă, î, ș, ț) + import io + sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') + sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace') + import asyncio import logging import os