win-unicode-console

0.5 · maintenance · verified Thu Apr 16

win-unicode-console is a Python library (current version 0.5) designed to enable proper Unicode input and output within the Windows console for Python versions up to 3.5. It addresses historical encoding issues when running Python scripts directly in the Windows console, allowing for correct display and handling of non-ASCII characters. The library is considered to be in maintenance mode, as Python 3.6 and newer versions have resolved the underlying console encoding issues via PEP 528.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to enable Unicode support and then print and (for Python 3) read Unicode text in the Windows console. It's crucial to call `win_unicode_console.enable()` early in your script. Ensure your console font (e.g., Lucida Console) supports the characters you wish to display.

import win_unicode_console

# Enable Unicode console support (should be called early)
win_unicode_console.enable()

# Now, print Unicode characters
print('こんにちは世界 (Hello world in Japanese)')
print('Français: bonjour, ça va? (French)')

# Try reading Unicode input (on Python 2, this might still need custom readline hook or specific configurations)
# For simple testing, focus on output initially.
# For Python 3, input() typically handles Unicode after enable().
# Example for Python 3:
try:
    user_input = input('Enter some Unicode text: ')
    print(f'You entered: {user_input}')
except Exception as e:
    print(f'Input error: {e}')

view raw JSON →