in reply to Creating (and using) a custom encoding.
See enc2xs (and its output) and PerlIO::via/File::BOM source
I vaguely recall having tried to make my own, but I can't find my notes :)