Badger...ncoding(3pm)

πŸ“¦
version 0.16 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu resolute

✨ Badger::Codec::Encoding ✨

okay bestie, welcome to Badger::Codec::Encoding πŸ’… β€” it's a User Contributed Perl Documentation page and it's literally the base class codec for all the different encodings. sit down, hydrate, let's get into it 🫢


🌸 NAME 🌸

Badger::Codec::Encoding β€” the base class codec for different encodings, no cap πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

like, here's the whole vibe in code form:

package My::Encoding::utf8;
use base 'Badger::Codec::Encoding';
use constant encoding => 'utf8';

package main;
my $codec = My::Encoding::utf8->new;
my $encoded = $codec->encode("...some utf8 data...");
my $decoded = $codec->decode($encoded);

see how easy that was?? iconic behaviour honestly ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. this module is a subclass of Badger::Codec, and it also does double duty as a base class for a whole lil family of specific encoding modules. it's giving matriarch. it's giving "everyone's mom at the function" πŸ‘‘


πŸ’… METHODS πŸ’…

🌈 encoding()

this constant method returns the encoding for the codec, periodt. subclasses are expected to redefine this method so it returns a string representing their own specific encoding. like, do your own thing babe, that's the whole point πŸ’œ

πŸ“ encode($data)

method for encoding data, obviously. it uses the encoding() method to figure out the encoding type, and then it calls the Encode encode() subroutine to do all the hard work. queen doesn't do her own heavy lifting πŸ’…

$encoded = $codec->encode($uncoded);

🧚 decode($data)

method for decoding data. same deal β€” it hits up the encoding() method to find the encoding type, then calls the Encode decode() subroutine to do all the hard work. teamwork makes the dream work fr fr 🌸

$decoded = $codec->decode($encoded);

⭐ encoder()

this method returns a subroutine reference that you can call to encode data. so you get a lil function you can pass around like a trading card 😭

my $encoder = $codec->encode;
$encoded = $encoder->($data);

πŸ”₯ decoder()

this method returns a suboroutine reference that you can call to decode data. yes, "suboroutine" β€” that's what the original says, we do not edit the sacred texts πŸ™ˆ

my $decoder = $codec->decode;
$decoded = $decoder->($data);

πŸ‘‘ AUTHOR πŸ‘‘

Andy Wardley <http://wardley.org/> β€” a whole legend 🫢


Copyright (C) 2005-2009 Andy Wardley. All rights reserved.

(yes bestie, all of them. every single right. reserved.) ✨


🌟 SEE ALSO 🌟

go read these next, they're all in the same cinematic universe:

  • Encode
  • Badger::Codec::Encode
  • Badger::Codec::Unicode
  • Badger::Codecs
  • Badger::Codec

and that's the whole page bestie!! this was served up by perl v5.36.0 on 2023-08-28, and yeah the title got squished into Badger...ncoding(3pm) like a lil nickname πŸ₯Ή β€” go forth and encode, main character πŸ’œπŸ¦‹πŸŽ€

πŸ“¦ where this page comes from