Badger...:Encode(3pm)
β¨ Badger::Codec::Encode β¨
okay bestie so this is a page from the User Contributed Perl Documentation for Badger::Codec::Encode β and it's about to be your new fave little wrapper, fr fr π
πΈ NAME πΈ
Badger::Codec::Encode β it's a codec wrapper around Encode. that's it, that's the whole vibe. tiny but mighty π
π SYNOPSIS π
use Badger::Codec::Encode;
my $codec = Badger::Codec::Encode->new();
my $encoded = $codec->encode( utf8 => "...some utf8 data..." );
my $decoded = $codec->decode( utf8 => $encoded );
see how clean that is?? obsessed πβ¨
π¦ DESCRIPTION π¦
so this module is a subclass of Badger::Codec and it's basically the thinnest little wrapper around the Encode module. like, it's barely doing anything on its own, and honestly? iconic. it exists purely so it can have a consistent API with all the other Badger::Codec modules, and to make codec chaining happen. team player energy π
you'd normally use a codec through the Badger::Codecs module, like this:
use Badger::Codecs
codec => 'encode';
my $encoding = 'UTF-8';
my $uncoded = "...some UTF-8 data...";
my $encoded = encode($encoding, $uncoded);
my $decoded = decode($encoding, $encoded)
and bestie, that is literally identical to just using the Encode module directly:
use Encode; # also exports encode()/decode()
plus, a Badger::Codec::Encode object will be available through the codec() subroutine:
my $encoded = codec->encode($encoding, $uncoded);
my $decoded = codec->decode($encoding, $encoded)
no cap, that's the whole thing π«Ά
π METHODS π
π encode($encoding, $data)
the encoding method π it just forwards all its arguments straight to the Encode encode() method. first argument = the encoding, second argument = the data you wanna encode. slay.
$encoded = Badger::Codec::Encode->encode( utf8 => $data );
π decode($encoding, $data)
the decoding method π« and yeah, same deal β it forwards all arguments to the Encode decode() method. first argument is the encoding, second is the data to decode. periodt.
$decoded = Badger::Codec::Encode->decode( utf8 => $encoded );
π§ encoder()
this one returns a reference to the actual real subroutine doing all the encoding work β aka the encode() function over in Encode. the main character behind the scenes β¨
π decoder()
and this one returns a reference to the actual real subroutine doing all the encoding work β aka the decode() method over in Encode. yup, the docs say "encoding work" for the decoder too, and we're not gonna mess with that, we're just gonna report it faithfully π
π AUTHOR π
Andy Wardley <http://wardley.org/> β ty for your service, king π«‘
π COPYRIGHT π
Copyright (C) 2005-2009 Andy Wardley. All rights reserved.
π SEE ALSO π
EncodeBadger::CodecsBadger::CodecBadger::Codec::Unicode
okay that's the whole page bestie, go forth and encode responsibly π β¨
perl v5.36.0 Β· 2023-08-28 β mwah, xoxo, and remember: chaining codecs is self-care ππ¦π
π¦ where this page comes from
- debian trixie: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms