host_env: Don't truncate two byte wchar_t - #8296
Conversation
Casting a u32 to a u16 would truncate the value. It's safer to use Wtf::encode_wide which already handles converting a CodePoint to a u16. I removed vec_into_bytes because it was only used in two places. The function was unsound for T but sound in the way RustPython used it (POD to POD, less strict alignment). AI disclosure: I linted this code with AI. I found this issue by accident while working on another patch in which I introduced a similar mistake. AI caught that mistake, so I linted the original code to cross-check it. I wrote the code myself in both instances. Assisted-by: Codex:gpt-5.4
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughWide-character helpers now support compile-time decoding and platform-dependent null-terminated byte generation. UTF-16 encoding explicitly flattens native-endian code units and appends a wide-character terminator. ChangesWide-character encoding
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
youknowone
left a comment
There was a problem hiding this comment.
good, i didn't think about this before, thanks!
Casting a u32 to a u16 would truncate the value. It's safer to use
Wtf8::encode_widewhich already handles converting a CodePoint to a u16.I removed
vec_into_bytesbecause it was only used in two places. The function was unsound for T but sound in the way RustPython used it (POD to POD, less strict alignment).AI disclosure: I linted this code with AI. I found this issue by accident while working on another patch in which I introduced a similar mistake. AI caught that mistake, so I linted the original code to cross-check it. I wrote the code myself in both instances.
Assisted-by: Codex:gpt-5.4
Summary
wchar_tbeing truncated fromu32tou16instead of correctly being encoded.Summary by CodeRabbit
Bug Fixes
Refactor