in reply to Re^2: Determine encoding of STDOUT
in thread Determine encoding of STDOUT

So you need some other mechanism for signaling encoding. For example have the user provide some environment variables if the encoding is different than UTF-8.