freonpsandoz has asked for the wisdom of the Perl Monks concerning the following question:
How should output from a command, executed using qx or backticks, that may contain non-ASCII characters, be converted to a correct internal representation for processing and output to a UTF-8 file? A user on nisus.com recommended using utf8::decode. This only seems to work for me (Windows platform) if the active console code page is 1252. On my system, the active CP seems to change between 437 and 1252 at times, so this doesn't work for me. I can set the CP to 437 (which is what I believe it should be) using Win32::Console::OutputCP and then convert it from cp437 using Encode::decode, but I'm not sure if this is the right way. Related question: why doesn't Perl handle this conversion itself by determining what command output encoding is in effect and converting as needed? Are there some platforms on which the character encoding of command output cannot be determined? Thanks.