Skip to content

✨ feat(mq-lang): add encode/decode builtins for text encoding conversion - #2221

Merged
harehare merged 2 commits into
mainfrom
feat/encode-decode-builtin
Aug 18, 2026
Merged

✨ feat(mq-lang): add encode/decode builtins for text encoding conversion #2221
harehare merged 2 commits into
mainfrom
feat/encode-decode-builtin

Conversation

@harehare

Copy link
Copy Markdown
Owner

Summary

Adds decode(bytes, label): string and encode(text, label): bytes builtins backed by encoding_rs, using WHATWG encoding labels (e.g. "shift_jis", "euc-jp", "utf-16le"). Both error on invalid byte sequences / unmappable characters rather than silently substituting, to avoid silent mojibake. Also registers the signatures in mq-check's type checker.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed
  • I added a changelog entry if this is a user-facing change

Additional Context

Adds `decode(bytes, label): string` and `encode(text, label): bytes`
builtins backed by encoding_rs, using WHATWG encoding labels
(e.g. "shift_jis", "euc-jp", "utf-16le"). Both error on invalid
byte sequences / unmappable characters rather than silently
substituting, to avoid silent mojibake. Also registers the
signatures in mq-check's type checker.
The encode/decode builtin docs only gave a few example labels, with no
indication of what the full set of accepted WHATWG encoding labels is.
@harehare
harehare force-pushed the feat/encode-decode-builtin branch from 367a8d1 to d96a9ff Compare August 18, 2026 13:52
@codspeed-hq

codspeed-hq Bot commented Aug 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing feat/encode-decode-builtin (d96a9ff) with main (13b4392)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (a059a66) during the generation of this report, so 13b4392 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@harehare
harehare merged commit 3798621 into main Aug 18, 2026
13 checks passed
@harehare
harehare deleted the feat/encode-decode-builtin branch August 18, 2026 23:28
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.

1 participant