https://gitlab.synchro.net/main/sbbs/-/commit/525bfd166fe44c4405da4ecb
Modified Files:
src/sbbs3/chat.cpp
Log Message:
chat: emit UTF-8 guru replies correctly to UTF-8 terminals (fix mojibake)
Guru replies come off the LLM as UTF-8, but they were pushed through CP437-assuming output primitives that re-encode each byte to the
terminal charset. On a UTF-8 terminal this double-encoded every
multibyte character into mojibake (e.g. a curly apostrophe shown as
three glyphs), and any node-spy (sbbsctrl, mqtt_spy.js) mirroring the
node's byte stream saw the same corruption.
Fix both output paths:
- Multinode (chat_llm_multinode_turn): stop pre-converting the reply to
CP437 based on the reader's terminal and emit with bprintf(P_AUTO_UTF8,
...). The reply stays UTF-8; bputs() adapts per terminal -- raw UTF-8
to a UTF-8 term, print_utf8_as_cp437() to a CP437 term.
- 1-on-1 streamed and non-streamed (simulate_type, the shared chokepoint
reached via js_simulate_type and chat_llm_session): when the terminal
is UTF-8, emit each multibyte codepoint atomically via bputs(seq,
P_UTF8) instead of byte-by-byte outchar(). Typo simulation correctly
applies to ASCII only. Robust to a codepoint split across SSE tokens
(bytes still go out raw and in order). The speed_factor<=0 fast path
uses P_AUTO_UTF8.
Co-Authored-By: Claude Opus 4.8 <
noreply@anthropic.com>
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net