Depends on what exactly you mean by "input". If you're referring to data read from an external file, using the PerlIO layer (your latter two variants) is certainly the way to go — except that reading from a file ("<:...") would decode, not encode, as you say in your question; in order to encode you'd need to write to the file...
See also the open pragma, -C and utf8.
In reply to Re: how to use Encode qw(all)
by almut
in thread how to use Encode qw(all)
by swilting
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |