✨ feat(mq-lang): add encode/decode builtins for text encoding conversion - #2221
Merged
Conversation
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
force-pushed
the
feat/encode-decode-builtin
branch
from
August 18, 2026 13:52
367a8d1 to
d96a9ff
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
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
Adds
decode(bytes, label): stringandencode(text, label): bytesbuiltins 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
Checklist
cargo fmtandcargo clippyand addressed any warningsjust test-alland all tests pass/docs, crateREADME.md) if neededAdditional Context