open
https://gitlab.synchro.net/main/sbbs/-/work_items/1419
2026-11-24 10:04:12 -0800
## Summary
User record strings (alias, real name, handle, note, address, location, comment) are stored as CP437 bytes today, and every length limit (`LEN_ALIAS`, `LEN_NAME`, `LEN_ADDRESS`, ...) is a byte count that the UI also uses as a column count. Users on UTF-8 terminals, and users of the web interface, can't enter names or locations outside CP437.
Proposal: make **UTF-8 the stored encoding** for user record strings, using a **one-time conversion** at upgrade time (coordinated upgrade of every host sharing `data/user/`), and replace the fixed-width `data/user/name.dat` with a new index file (proposed name `data/user/user.idx`).
## Why a one-time conversion
Options considered:
- **One-time conversion (chosen).** Nearly every record is pure ASCII, which is byte-identical in CP437 and UTF-8, so only records with high-bit characters change. After the conversion, all code can assume UTF-8 with no per-record branching. It needs every host sharing `data/user/` to upgrade together, which is acceptable here (and is already required by the `name.dat` format change below).
- **Per-record encoding indicator** (the user-record equivalent of SMB's per-message `MSG_HFIELDS_UTF8`): allows lazy migration and mixed versions, but every reader has to branch on the indicator indefinitely. Only worth it if mixed-version access to a shared `data/user/` had to be supported.
- **Per-field indicator:** rejected. All text fields of a record are written by the same code path in the same build, so they don't end up in mixed encodings in practice.
## Proposed work
### 1. Storage and upgrade
- [ ] Upgrade tool (following `upgrade_to_v320.c`): convert each high-bit string field of `user.tab` from CP437 to UTF-8, and build `user.idx` from the converted records. Back up `user.tab` and `name.dat` first.
- [ ] Decide how the tool recognizes an already-converted `user.tab` so a second run doesn't double-encode (e.g. a marker in the file, or the presence of `user.idx`).
- [ ] Check the converted records still fit in `USER_RECORD_LINE_LEN` (1000 bytes). Worst case each high-bit CP437 character becomes 3 bytes.
### 2. Length limits: characters vs. bytes
- [ ] Split each `LEN_*` for the affected fields into a **character limit** (what the user may enter, validated and displayed) and a **byte capacity** (storage, buffers). About 90 uses of `LEN_ALIAS`/`LEN_NAME` in `src/` need to be checked for which meaning they rely on.
- [ ] Input prompts must count characters (or terminal columns, for wide CJK characters) rather than bytes, and must not split a multi-byte sequence.
### 3. New name index: `user.idx`
`name.dat` uses fixed 27-byte slots (`LEN_ALIAS` + CRLF), too small for a 25-character UTF-8 alias.
- [ ] Define the `user.idx` format (wider fixed slots, e.g. `LEN_ALIAS * 4` bytes, keeps O(1) seek by user number).
- [ ] Update `USER_INDEX_FILENAME` and `getusername()`, `putusername()`, `total_users()`, `finduser()`/`matchuser()`.
- [ ] Other code that opens `name.dat` directly: `src/sbbs3/ctrl/NodeFormUnit.cpp`, `src/doors/termgfx/sbbs_node.c`, `xtrn/sdk/xsdk.c`, and the name.dat/user.tab mismatch repair in `src/sbbs3/main.cpp`.
- [ ] Third-party doors and utilities that read `name.dat` will break. Note this in the release notes, and decide whether to keep writing a legacy `name.dat` (CP437-converted, truncated) for a release or two.
### 4. Name lookup and uniqueness
- [ ] Normalize to NFC before storing and comparing.
- [ ] Replace byte-wise case-insensitive comparison with Unicode case folding in user lookup and duplicate-name checks.
- [ ] Lookalike characters: an alias such as "Sysop" spelled with a Cyrillic "¨" would pass a byte or code point uniqueness check. Options: allow only characters that `utf8_to_cp437()` can represent in aliases (at least initially), or compare a confusables skeleton as well.
- [ ] Also check uniqueness of the down-converted form (see 5), so two aliases can't become indistinguishable on CP437 terminals or in QWK/FidoNet.
### 5. Down-conversion for legacy consumers
Each needs a defined, lossy conversion from the stored UTF-8 string:
- [ ] CP437, PETSCII and ASCII terminals (`utf8_to_cp437()` with a fallback character)
- [ ] QWK packets and REP import (sender/recipient names)
- [ ] FidoNet `From`/`To` fields (or `CHRS: UTF-8` where supported)
- [ ] Door drop files (DOOR.SYS, DORINFO*.DEF, etc.) and the `xtrn` environment - [ ] Message headers posted by the user: set `MSG_HFIELDS_UTF8` when the name is non-ASCII
- [ ] Logs (UTF-8 is fine) and MQTT topics/payloads
### 6. JavaScript API
- [ ] Decide what `user.alias`, `user.name`, `user.location`, etc. return (UTF-8 bytes vs. decoded text) and match the existing convention for `MSG_HFIELDS_UTF8` message header fields. Setters must validate UTF-8.
- [ ] Review stock modules that write user strings (new-user scripts, webv4 profile editing, `makeuser`, user editors).
### 7. Configuration and editors
- [ ] SCFG, `useredit`, `sbbsctrl` user editor, the Terminal Server user editor (`;EDIT`): accept and display UTF-8 or degrade correctly.
- [ ] `text/name.can` and other `.can` filters: matched against the UTF-8 string, so the filter files need to be UTF-8 (or converted on load).
## Scope
Only the free-text fields change: alias, name, handle, note, address, location, comment. Phone, zip code, netmail address, IP address, host name and the remaining fields stay ASCII.
Related: #1319 (Unicode JS APIs), #1200, #1317.
- *Authored by Claude (Claude Code), on behalf of @rswindell*
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net