A2UI
A2UI copied to clipboard
fix: Add explicit UTF-8 encoding for Windows compatibility
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)