From f7cd4fde040198747cc8f5d0b90caa17f8277abc Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Sat, 22 Aug 2026 11:31:43 -0700 Subject: [PATCH] Declare UTF-8 for the stylesheet and served text types style.css uses non-ASCII glyphs in CSS content (panel arrow, pin). Without a declared encoding the browser can fall back to Latin-1 for the stylesheet and render them as mojibake, which happened once in the preview. @charset at the top of style.css fixes it everywhere; serve.py also sends charset=utf-8 for html/css/js/json. Co-Authored-By: Claude Fable 5 --- server/serve.py | 9 ++++++++- web/style.css | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/serve.py b/server/serve.py index 2c64421..c90650f 100644 --- a/server/serve.py +++ b/server/serve.py @@ -42,7 +42,14 @@ CONFIG_LOCK = threading.Lock() class Handler(http.server.SimpleHTTPRequestHandler): extensions_map = {**http.server.SimpleHTTPRequestHandler.extensions_map, - ".webp": "image/webp"} + ".webp": "image/webp", + # Explicit charset: style.css carries non-ASCII glyphs + # (arrow, pin) and a stylesheet without a declared + # encoding can fall back to Latin-1 and render mojibake. + ".html": "text/html; charset=utf-8", + ".css": "text/css; charset=utf-8", + ".js": "text/javascript; charset=utf-8", + ".json": "application/json; charset=utf-8"} editable = False # SimpleHTTPRequestHandler defaults to HTTP/1.0, which closes the socket diff --git a/web/style.css b/web/style.css index 55b2a72..765a86b 100644 --- a/web/style.css +++ b/web/style.css @@ -1,3 +1,4 @@ +@charset "UTF-8"; :root { --bg: #14161a; --panel: #1e2229ee;