Skip to content

fix(builtins): use char-based precision truncation in printf#467

Merged
chaliy merged 1 commit intomainfrom
claude/fix-435-Y2nIj
Mar 2, 2026
Merged

fix(builtins): use char-based precision truncation in printf#467
chaliy merged 1 commit intomainfrom
claude/fix-435-Y2nIj

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 2, 2026

Summary

  • printf string precision (%.5s) used byte slicing which panicked on multi-byte UTF-8
  • Changed to chars().take(prec).collect() for safe char-based truncation

Test plan

  • Unit test: test_precision_multibyte_utf8
  • Unit test: test_precision_cjk

Closes #435

printf %.*s was using byte slicing which panics when the truncation
point falls inside a multi-byte UTF-8 character. Now uses
chars().take(prec) for safe char-based truncation.

Closes #435

https://claude.ai/code/session_01WZjYqxm5xMPAEe7FSHJkDy
@chaliy chaliy force-pushed the claude/fix-435-Y2nIj branch from a040c2c to f791d8f Compare March 2, 2026 01:37
@chaliy chaliy merged commit d2f533d into main Mar 2, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[M-12] printf precision truncation panics on multi-byte UTF-8 (TM-UNI-016)

2 participants