Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^4: unpacking wmic command's unicode output

by ikegami (Pope)
on Nov 12, 2008 at 18:02 UTC ( #723231=note: print w/replies, xml ) Need Help??

in reply to Re^3: unpacking wmic command's unicode output
in thread unpacking wmic command's unicode output

I don't get the -CS. Does wmic really output UTF-8? Wouldn't it be more appropriate to use wmic process | perl

Replies are listed 'Best First'.
Re^5: unpacking wmic command's unicode output
by BrowserUk (Pope) on Nov 12, 2008 at 18:26 UTC
    Does wmic really output UTF-8?

    It appears it does (some form of unicode anyway), if you redirect its output to a file (or via a pipe):

    c:\test>wmic.exe process > junk c:\test>u:head -c 200 junk  ■C a p t i o n C o m m a n d L i n +e

    That first spludge(*) is the LE BOM 0xfffe. (It was a spludge when I c&p'd it!)

    Probably utf-16le I think, but whatever it is, using -CS does seem to cause perl to work out what it is getting and treat it appropriately:

    c:\test>wmic.exe process | perl -CS -pe1 > junk c:\test>u:head -c 200 junk Caption CommandLine

    Whether by accident or design, it is useful.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I didn't suggest
      wmic.exe process > junk
      I suggested you drop the -CS, so you need to compare
      wmic.exe process | perl -CS -pe1 > junk
      wmic.exe process | perl -pe1 > junk

      It's simple,

      • If wmic outputs "C a p t i o n ", then it's cleary using a 16-bit encoding and -CS is guaranteed to hurt.
      • If wmic doesn't output "C a p t i o n ", then you've lost your justification for using -CS.

        Now I'm confused. a) how would it hurt? b) Why does it seem not to hurt in my use now?

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://723231]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2018-07-19 21:00 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (420 votes). Check out past polls.