fix: isolate canvas CJK strings and guard build encoding

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-12 09:32:59 +08:00
parent 2ecd300ada
commit 288ebf4c90
7 changed files with 431 additions and 53 deletions

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""Diagnose TopologyCanvas.tsx encoding / CJK corruption."""
from __future__ import annotations
import re
from pathlib import Path
p = Path(__file__).resolve().parents[1] / "src" / "TopologyCanvas.tsx"
raw = p.read_bytes()
print("size", len(raw))
print("bom", raw[:3] == b"\xef\xbb\xbf")
try:
text = raw.decode("utf-8")
print("utf8: OK")
except UnicodeDecodeError as e:
print("utf8: FAIL", e)
print("bad-byte context:", raw[max(0, e.start - 30) : e.start + 30])
text = raw.decode("latin1")
quoted = re.findall(r'"\?{2,}"', text)
print("quoted ?? count:", len(quoted))
print("cjk chars:", len(re.findall(r"[\u4e00-\u9fff]", text)))
for i, line in enumerate(text.splitlines(), 1):
if '["select"' in line or "title=" in line and "?" in line and "??" in line:
if i >= 1180 and i <= 1360:
print(f"{i}: {line.strip()[:100]}")