feat: [US-002] Fix UTF-8 encoding for Windows console
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 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,19 @@ ROA2WEB Unified Backend - Single FastAPI Application
|
|||||||
Consolidates Reports, Data Entry, and Telegram modules into one process
|
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 asyncio
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|||||||
Reference in New Issue
Block a user