in reply to unpacking wmic command's unicode output

It's probably easier to open the file as UTF-16

open my $fh, "<:encoding(UTF-16)", $filename or ...

and then operate on the resulting text string as usual...

(Use UTF-16LE, in case the file should have no BOM.)

Replies are listed 'Best First'.
Re^2: unpacking wmic command's unicode output
by goibhniu (Hermit) on Nov 11, 2008 at 19:53 UTC

    That's a good idea and I may resort to that. I had it in my head to get this piped from the output. Can I open a pipe as UTF-16?

    Update: I was thinking of a syntax like:
    wmic process | find /i "myprog.exe" | getmyfields.pl


    #my sig used to say 'I humbly seek wisdom. '. Now it says:
    use strict;
    use warnings;
    I humbly seek wisdom.
        I don't get the -CS. Does wmic really output UTF-8? Wouldn't it be more appropriate to use wmic process | perl script.pl?

        So it DOES! Thank you, thank you, O sage. I'd have been weeks in perlpacktut were it not for this elegant solution!


        #my sig used to say 'I humbly seek wisdom. '. Now it says:
        use strict;
        use warnings;
        I humbly seek wisdom.