refactor: remove Encode dependency, use core utf8::#18
Closed
Koan-Bot wants to merge 2 commits into
Closed
Conversation
Replace the private Encode::_utf8_on() with utf8::decode() and Encode::is_utf8() with utf8::is_utf8(). Both are core Perl functions available since 5.8 — no module import needed. utf8::decode() is superior to _utf8_on(): it validates the byte sequence as legal UTF-8 before setting the flag, whereas _utf8_on() blindly flips the flag even on invalid bytes. This removes Encode from runtime prerequisites entirely (dist.ini, cpanfile, Makefile.PL), making the dependency tree lighter. Supersedes #10. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The maint audit (PR #15) fixed colors.pl but missed this one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 22, 2026
This was referenced Apr 23, 2026
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.
What
Replace
Encode::_utf8_on()+Encode::is_utf8()with coreutf8::decode()+utf8::is_utf8(), removing theEncodemodule from runtime dependencies entirely.Why
Encode::_utf8_on()is a private API (leading underscore = not for public use). It blindly sets the UTF-8 flag without validating the byte sequence.utf8::decode()is a core Perl function (since 5.8, no import needed) that validates the bytes are legal UTF-8 before setting the flag — strictly better behavior.This also makes the module lighter: one fewer runtime dependency.
Supersedes #10 which replaced
_utf8_onwithutf8::upgrade— butupgradeis wrong here (it re-encodes Latin-1 → UTF-8, causing double-encoding of already-UTF-8 bytes).utf8::decodeis the correct replacement.How
Encode::_utf8_on($s)→utf8::decode($s)(validates + sets flag)Encode::is_utf8($s)→utf8::is_utf8($s)(core equivalent)use Encode ()from WebHook.pmEncodefrom dist.ini, cpanfile, Makefile.PL prerequisitesuse Slack::WebHookinexamples/start-end.plTesting
prove -Ilib -v t/hooks.t— 48/48 pass\xc3\xa9) confirm correct behavior🤖 Generated with Claude Code
Quality Report
Changes: 6 files changed, 5 insertions(+), 11 deletions(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline