https://gitlab.synchro.net/main/sbbs/-/commit/3b412fa2e195fe1e0a3a8cb1
Modified Files:
src/encode/utf8.c
Log Message:
utf8: make utf8_to_cp437_str() actually convert
The function looked up every codepoint with unicode_to_cp437() and
skipped any that returned zero. That function is a table of approximations
for codepoints CP437 cannot represent directly, so it returns zero for all
of U+0020 through U+007E - meaning every ASCII character was discarded and "Hello, world!" converted to an empty string. It also asked utf8_getc()
for a character while passing the space remaining in the destination as
the number of readable source bytes, and ignored 'minval' entirely.
Convert the way print_utf8_as_cp437() does: pass ASCII straight through
(CP437 and ASCII agree below 0x80), then prefer an exact match from cp437_unicode_tbl before falling back to the unicode_to_cp437()
approximation, and emit an inverted question mark for what remains rather
than dropping it. Codepoints below 'minval' are left untranslated, as in cp437_to_utf8_str(). utf8_getc() is now given the remaining source length.
The function has had no callers since it was added, which is why none of
this surfaced.
Co-Authored-By: Claude Opus 5 (1M context) <
noreply@anthropic.com>
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net