A2UI icon indicating copy to clipboard operation
A2UI copied to clipboard

fix: Add explicit UTF-8 encoding for Windows compatibility

Open Mag1cFall opened this issue 10 months ago • 0 comments

Problem

The sample agents (restaurant_finder and contact_lookup) fail on Windows with the following error when reading JSON data files:

UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 216: illegal multibyte sequence

Cause

Python's open() function uses the system default encoding, which is GBK/BIG5 on Chinese Windows systems (and other non-UTF-8 locales). The JSON data files are UTF-8 encoded, causing the decode error.

Fix

Explicitly specify encoding='utf-8' when opening JSON files:

# Before
with open(file_path) as f:

# After
with open(file_path, encoding='utf-8') as f:

Testing

  • Demo runs successfully on Windows 11 after fix
  • No impact on Linux/macOS (UTF-8 is the default)

Mag1cFall avatar Jan 04 '26 13:01 Mag1cFall