Encode...tector(3pm)
π Encode::Detect::Detector β the perl manual page, bestie edition π
okay so this is the page for Encode::Detect::Detector, a User Contributed Perl Documentation page. yes it's a mouthful, no we're not renaming it, it's iconic as is π
β¨ NAME β¨
Encode::Detect::Detector β it detects the encoding of data. that's it, that's the whole job, and honestly? slay π
πΈ SYNOPSIS πΈ
here's the whole vibe in code form, copy it exactly or perish:
use Encode::Detect::Detector;
my $charset = detect($octets);
my $d = new Encode::Detect::Detector;
$d->handle($octets);
$d->handle($more_octets);
$d->end;
my $charset = $d->getresult;
two ways to do it: the one-liner detect function, or the object route where you feed it chunks like you're hand-feeding a picky little creature π¦
π«Ά DESCRIPTION π«Ά
this module is literally just an interface to Mozilla's universal charset detector β the thing that figures out which charset was used to encode your data. it's giving "mystery solved, detective era" πβ¨
π METHODS π
π $charset = Encode::Detect::Detector->detect($octets)
detects the charset used to encode the data sitting in $octets, and returns the charset's name. returns undef if it can't be determined with sufficient confidence β yes, the detector has standards, as it should π
π $d = Encode::Detect::Detector->new()
creates a fresh new Encode::Detect::Detector object and hands it to you. main character energy, brand new, no baggage β¨
π $d->handle($octets)
hands the detector one more chunk of data to examine. you can call this multiple times β feed it, feed it, feed it, it's hungry π
returns zero on success, nonzero if a memory allocation failed. (memory allocation failing is NOT the vibe, but like, now you know π)
π $d->eof
tells the detector there's no more data to examine. and ngl, in many cases this is literally necessary for the detector to actually make a decision on the charset. so don't skip it, bestie π«Ά
π $d->reset
resets the detector all the way back to its initial state. clean slate, fresh start, we love a glow-up π
π $d->getresult
returns the name of the detected charset, or "undef" if no charset has (yet) been decided upon. and the cute part? you can call it at any time β
π¦ SEE ALSO π¦
Encode::Detect
π AUTHOR π
John Gardiner Myers <jgmyers@proofpoint.com> β thank you for your service π«‘π
π SUPPORT π
for help and thank-you notes, e-mail the author directly (yes, thank-you notes are literally listed, be polite, it's cute πΈ).
to report a bug, submit a patch, or add to the wishlist, please visit the CPAN bug manager at: http://rt.cpan.org
lowkey a reminder: that's the CPAN bug manager link, not a vibe check. go there for bugs and patches only π
and that's the whole page, bestie!! β¨ this one's from perl v5.42.0, dated 2013-03-27, and it's part of the User Contributed Perl Documentation collection β so go forth, detect those charsets, and remember: eof in the methods, end in the synopsis, and we don't ask questions about it ππ π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Encode-Detect 1.01-bp160.4.13 Β· MPL-1.1
- opensuse-leap 16.0: perl-Encode-Detect 1.01-bp160.4.13 Β· MPL-1.1
- opensuse-leap 16.0: perl-Encode-Detect 1.01-bp160.4.13 Β· MPL-1.1
- opensuse-leap 16.0: perl-Encode-Detect 1.01-bp160.4.13 Β· MPL-1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms