mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 13:39:50 +08:00
web_fetch decoded every response with httpx's response.encoding, which only reads the Content-Type header and otherwise defaults to UTF-8. Pages that declare their charset in the markup (common for GBK, Shift_JIS and EUC-KR sites) came back as replacement characters in the web_fetch tool, Immersive Reading URL imports and website knowledge-base crawls. Pick the charset the way a browser does: byte-order mark, then the Content-Type charset, then a <meta> declaration in the first 1024 bytes, then UTF-8. Labels such as gb2312 and iso-8859-1 decode as their superset encodings (gb18030, cp1252), matching the WHATWG Encoding standard.