From da223014c02e783a2c0117130e5cabf2a0d12fbb Mon Sep 17 00:00:00 2001 From: C1-BA-B1-F3 Date: Thu, 25 Jun 2026 09:39:24 +0800 Subject: [PATCH] fix: force UTF-8 stdout in Playwright patterns to prevent UnicodeEncodeError on Windows On Windows, Python defaults sys.stdout.encoding to cp1252, which crashes when aria_snapshot() returns characters outside that codepage (e.g. CJK, math symbols, typography glyphs). Adding sys.stdout.reconfigure(encoding='utf-8') to the canonical code skeletons makes the patterns portable. Fixes #7 --- skills/webwright/reference/playwright_patterns.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/skills/webwright/reference/playwright_patterns.md b/skills/webwright/reference/playwright_patterns.md index 5ba1565..0976343 100644 --- a/skills/webwright/reference/playwright_patterns.md +++ b/skills/webwright/reference/playwright_patterns.md @@ -16,8 +16,12 @@ the first task. python - <<'PY' import asyncio import os +import sys from pathlib import Path +# Force UTF-8 stdout to avoid UnicodeEncodeError on Windows (cp1252) +sys.stdout.reconfigure(encoding="utf-8") + from playwright.async_api import async_playwright WORKSPACE = Path(os.environ.get("WORKSPACE_DIR", ".")) @@ -127,8 +131,12 @@ Guidelines for the interactive path: - print the final datum at the end of the log. ```python -import asyncio, os +import asyncio, os, sys from pathlib import Path + +# Force UTF-8 stdout to avoid UnicodeEncodeError on Windows (cp1252) +sys.stdout.reconfigure(encoding="utf-8") + from playwright.async_api import async_playwright RUN_DIR = Path(__file__).parent