To me, this looks like an XY Problem. It doesn't sound like a good thing to make a "lower level routine" distinguish between different kinds of file handles with different IOLayers tied upon them. Where does your routine get filehandles from? Why they are opened in different modes? Wouldn't it be a better idea to binmode it some appropriate IOLayer like :utf8 or :encoding(...) on an upper level of subroutines?
Anyway, you can use PerlIO::get_layers($fh) to get the list of layer names on a filehandle (got from PerlIO perldoc page). Checking whether filehandle is in utf-8 mode is then reduced to grepping for the "utf8" string (usually the last element of the array).
In reply to Re: How to tell if a stream is already in UTF8 mode?
by aitap
in thread How to tell if a stream is already in UTF8 mode?
by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |