Fss-Rag-Mini/mini_rag/claude_rag/windows_console_fix.py
BobAi dc866e6ce3 MAJOR: Remove all Claude references and rename to Mini-RAG
Complete rebrand for v1.0-simple-search branch:

Directory Changes:
- claude_rag/ → mini_rag/ (preserving git history)

Content Changes:
- Updated all imports: from claude_rag → from mini_rag
- Updated all file paths: .claude-rag → .mini-rag
- Updated documentation and comments
- Updated configuration files and examples
- Updated all tests to use mini_rag imports

This ensures complete independence from Claude/Anthropic
branding while maintaining all functionality and git history.

Simple branch contains the basic RAG system without LLM features.
2025-08-12 19:27:55 +10:00

63 lines
1.7 KiB
Python

"""
Windows Console Unicode/Emoji Fix
Reliable Windows console Unicode/emoji support for 2025.
"""
import sys
import os
import io
def fix_windows_console():
"""
Fix Windows console to properly handle UTF-8 and emojis.
Call this at the start of any script that needs to output Unicode/emojis.
"""
# Set environment variable for UTF-8 mode
os.environ['PYTHONUTF8'] = '1'
# For Python 3.7+
if hasattr(sys.stdout, 'reconfigure'):
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')
if hasattr(sys.stdin, 'reconfigure'):
sys.stdin.reconfigure(encoding='utf-8')
else:
# For older Python versions
if sys.platform == 'win32':
# Replace streams with UTF-8 versions
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', line_buffering=True)
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', line_buffering=True)
# Also set the console code page to UTF-8 on Windows
if sys.platform == 'win32':
import subprocess
try:
# Set console to UTF-8 code page
subprocess.run(['chcp', '65001'], shell=True, capture_output=True)
except:
pass
# Auto-fix on import
fix_windows_console()
# Test function to verify it works
def test_emojis():
"""Test that emojis work properly."""
print("Testing emoji output:")
print(" Check mark")
print(" Cross mark")
print(" Rocket")
print(" Fire")
print(" Computer")
print(" Python")
print(" Folder")
print(" Search")
print(" Lightning")
print(" Sparkles")
if __name__ == "__main__":
test_emojis()