Repository navigation
UTF-8 BOM + $CODEPAGE sweep for user-facing text surfaces (37 files) - #152
Merged
Merged
Conversation
Apply the same UTF-8 BOM + {\$IFDEF FPC}{\$CODEPAGE UTF8}{\$ENDIF}
preamble that fixed the PASCLAW banner (PR #151) to every other
user-facing source file with non-ASCII bytes inside string literals.
Scope: 37 .pas files across cmd/, channels/, gateway/, mcp/, skills/,
tools/, tui/. Identified by grep'ing for "'[^']*[^\\x00-\\x7F][^']*'"
(non-ASCII byte inside single-quoted text) and filtering to the
directories that emit text to the user (CLI output, TUI, gateway
responses, channel-bot replies, tool error/status messages).
Pure-comment-only non-ASCII (em-dash in doc blocks, e.g. some lib
units like PasClaw.JSON.pas, PasClaw.Identity.pas) was excluded —
those bytes never reach a user-visible surface.
Preamble per file (identical to CliUI.pas from PR #151):
{\$IFDEF FPC}
{\$CODEPAGE UTF8}
{\$WARN IMPLICIT_STRING_CAST OFF}
{\$WARN IMPLICIT_STRING_CAST_LOSS OFF}
{\$ENDIF}
Plus a UTF-8 BOM (EF BB BF) at byte 0 of each file. Delphi
auto-detects the BOM and reads the source as UTF-8 regardless of
project setting — fixing the CP1252 misinterpretation that was
turning each UTF-8 byte of ✓ (E2 9C 93) or ╗ (E2 95 97) into three
separate CP1252 codepoints under build-delphi.bat. The FPC-only
block keeps literals stored as AnsiString CP_UTF8 (so Print/PrintLn
emits the original bytes unchanged on the wire) and silences the
6-warnings-per-line AnsiString↔UnicodeString conversion noise that
the BOM alone produces under FPC mode delphi.
Verified Linux+FPC:
- Full rebuild clean (18705 lines, 0 new warnings on swept files)
- make smoke — all 11 commands OK
- Banner bytes still e2 96 88 ... for U+2588 (no regression)
Files swept (37):
src/cmd/PasClaw.Cmd.{Agent,Auth,Cron,Gateway,MCP,Model,Onboard,
Post,Root,Serve,Session,Skills,Steer,Update,
Vault}.pas
src/pkg/channels/PasClaw.Channels.{Email,IRC,LINE,Matrix,Telegram,
WhatsApp}.pas
src/pkg/gateway/PasClaw.Gateway.{Server,ToolView}.pas
src/pkg/mcp/PasClaw.MCP.{Bridge,Catalog,Hub,OAuth}.pas
src/pkg/skills/PasClaw.Skills.{ClawHub,GitHub,PasClawHub}.pas
src/pkg/tools/PasClaw.Tools.{FS,Memory,Sandbox,ToolLoop,Vault,
WebFetch}.pas
src/pkg/tui/PasClaw.TUI.pas
Pattern is mechanical: one canonical preamble per file. Diff is
large but each file's change is the same six lines.
3 of 4 tasks
khongten001
pushed a commit
to khongten001/PasClaw
that referenced
this pull request
Jul 13, 2026
User report: \`────\` (U+2500 x 4) divider in fenced code-block output
mojibakes to \`────\` under build-delphi.bat. Classic UTF-8 -> CP1252
misinterpretation:
U+2500 in UTF-8 is E2 94 80. Read as CP1252:
E2 -> â
94 -> ”
80 -> €
The reflexive fix (UTF-8 BOM + {\$CODEPAGE UTF8} preamble like
PR FMXExpress#152 used) breaks Linux+FPC: with the directive, '•' / '│' /
'─' literals get stored as AnsiString CP_UTF8, then mixed-codepage
concatenation with Ansi.* fields triggers an implicit
UnicodeString round-trip, and the final cast back to AnsiString
drops U+2022 to '?'. Confirmed by direct byte dump — bullet output
became '?' (0x3F) after applying the preamble.
Switch to hex byte constants instead:
GLYPH_BULLET = #\$E2#\$80#\$A2; { U+2022 BULLET }
GLYPH_VBAR = #\$E2#\$94#\$82; { U+2502 BOX VERTICAL }
GLYPH_HBAR = #\$E2#\$94#\$80; { U+2500 BOX HORIZONTAL }
GLYPH_DIVIDER = GLYPH_HBAR x 4;
\`#\$XX\` constants are raw bytes — neither Delphi nor FPC tries to
transcode them through the source-file codepage. The bytes go
straight into the AnsiString and straight out to the terminal,
which is UTF-8 aware.
Verified Linux+FPC:
- make test-markdown-render -> all 12 cases OK (was breaking on
TestBulletList with the preamble approach)
- make smoke -> all 11 commands OK
- Byte-level check on fenced-code divider produces
e2 94 80 e2 94 80 e2 94 80 e2 94 80 — four correct UTF-8 box
horizontals.
Under Delphi: same byte sequence emitted by the same hex constants
— no source-file codepage involved.
Scoped to one file. The wider sweep (23 files identified with the
preamble pattern + non-ASCII literals) is the wrong target — same
mixed-codepage concat issue would surface there. If any of those
files mojibakes a glyph at runtime under build-delphi.bat, the
same byte-constant approach applies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Apply the same UTF-8 BOM +
{$IFDEF FPC}{$CODEPAGE UTF8}{$ENDIF}preamble that fixed the PASCLAW banner (#151) to every other user-facing source file with non-ASCII bytes inside string literals.Scope: 37 files across
cmd/,channels/,gateway/,mcp/,skills/,tools/,tui/. Identified by grep'ing for'[^']*[^\x00-\x7F][^']*'(non-ASCII byte inside single-quoted text) and filtering to directories that emit text to the user.Excluded: pure-comment-only non-ASCII (em-dash in doc blocks, e.g. some lib units like
PasClaw.JSON.pas,PasClaw.Identity.pas). Those bytes never reach a user-visible surface.Preamble (identical per file, same as PR #151)
Plus a UTF-8 BOM (
EF BB BF) at byte 0 of each file. Delphi auto-detects the BOM and reads the source as UTF-8 regardless of project setting — fixing the CP1252 misinterpretation that was turning each UTF-8 byte of✓(E2 9C 93) or╗(E2 95 97) into three separate CP1252 codepoints underbuild-delphi.bat.Verified Linux+FPC
make smoke— all 11 commands OKe2 96 88 ...for U+2588 (no regression)build-delphi.bat— only you can do this. Run any ofpasclaw onboard,pasclaw model show(has✓),pasclaw vault search fooand check that the status markers + box-drawing chars render correctly.Files swept (37)
src/cmd/PasClaw.Cmd.{Agent,Auth,Cron,Gateway,MCP,Model,Onboard,Post,Root,Serve,Session,Skills,Steer,Update,Vault}.passrc/pkg/channels/PasClaw.Channels.{Email,IRC,LINE,Matrix,Telegram,WhatsApp}.passrc/pkg/gateway/PasClaw.Gateway.{Server,ToolView}.passrc/pkg/mcp/PasClaw.MCP.{Bridge,Catalog,Hub,OAuth}.passrc/pkg/skills/PasClaw.Skills.{ClawHub,GitHub,PasClawHub}.passrc/pkg/tools/PasClaw.Tools.{FS,Memory,Sandbox,ToolLoop,Vault,WebFetch}.passrc/pkg/tui/PasClaw.TUI.pasDiff is large but mechanical — same six-line change per file. Reviewing one canonical change pattern (any file) covers all 37.
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code