Skip to content

Conversation

@715494637
Copy link

Problem Description

On Windows systems, the search.py script fails with a UnicodeEncodeError when outputting Unicode characters (such as warning symbols ). This is because Windows CMD defaults to GBK encoding, which cannot handle UTF-8 Unicode characters.

UnicodeEncodeError: 'gbk' codec can't encode character '\u26a0' in position 647: illegal multibyte sequence

Solution

Added Windows-specific encoding detection and UTF-8 output wrapping to ensure proper Unicode character display on all platforms.

Changes Made

  • Added sys and io imports for encoding handling
  • Added platform detection for Windows systems
  • Wrapped stdout with UTF-8 encoding when running on Windows
  • Added detailed comments explaining the fix

Technical Details

# Fix Windows encoding issue
if sys.platform == "win32":
    sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")

Impact

This fix ensures the skill works properly for Windows users, maintaining consistent output formatting across all platforms.

Related Issues

  • Cross-platform compatibility
  • Unicode character support in output

Fix Type: Bug Fix
Platforms Affected: Windows
Breaking Changes: None

Add Windows-specific encoding handling to prevent UnicodeEncodeError
when outputting Unicode characters (such as warning symbols) on Windows CMD.
This fix detects Windows platform and sets stdout encoding to UTF-8.
Fix: Windows Unicode encoding issue in search.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant