Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How can I get a Unicode @ARGV?

by Anonymous Monk
on Aug 31, 2012 at 03:04 UTC ( #990907=note: print w/replies, xml ) Need Help??


in reply to How can I get a Unicode @ARGV?

I have a script that packed as Executable

Which packer?

and the path passing in becomes ?????.

This part cmd.exe does on its own, you have to chcp 65001 to get it to not molest unicode, or use powershell

See also Win32::Unicode, Win32::Unicode::Native decodes @ARGV

Replies are listed 'Best First'.
Re^2: How can I get a Unicode @ARGV?
by exilepanda (Pilgrim) on Aug 31, 2012 at 04:20 UTC
    Which packer?
    I have Cava and PerlApp, but yet I only tried with PerlApp

    becomes ?????.
    Yes. it turns into question marks.

    ...chcp 65001...
    I think it's too late to chcp too. What I think is while the moment the file path is dropped to the exe file, it's already turned into "?????" before perl accept the argv.. But I have no way to know about...

    I use Win32::Unicode::* for other occasions and works fine, only require I have put the right String source first. And I am dead at the very first moment...

      Yes. it turns into question marks.... I think it's too late to chcp too.

      :) That wasn't a question, I was quoting the line I was responding to :)

      But I totally missed the drag/drop thing

      So you're seeing "??????" in the console? What is Data::Dumper output?

      I imagine using Win32::Unicode::Native ought to work, but if it doesn't, these two might

      Win32::CommandLine - Retrieve and reparse the Win32 command line

      update: it probably won't, no mention of unicode/wchar or GetCommandLineW

      Win32::Process::CommandLine - Perl extension for getting win32 process command line parameters

      But if they don't, then I think recompiling perl ( runperl.c ) with wmain ought to work, but then that might be tough to manage with with perlapp/cava, though it wouldn't surprise me if this step isn't necessary

      But, you know :) you could always compile a foo.exe which uses wmain and calls your perlapp packed perl.exe with -CSD or whatever :)

        Ok, I did some testing with PAR Packager, version 1.013 (PAR version 1.005)

         pp -M strict -M warnings -M Data::Dump -M Win32::Unicode::Native -M Win32::Process::CommandLine -M Win32::CommandLine   dragdropmeargv.pl

        #!/usr/bin/perl -- use strict; use warnings; use Data::Dump; dd \@ARGV; eval 'use Win32::Unicode::Native;'; dd \@ARGV; { use Win32::Process::CommandLine; Win32::Process::CommandLine::GetPidCommandLine($$, my $str); dd $str; } use Win32::CommandLine(); dd [ Win32::CommandLine::argv() ]; dd [ Win32::CommandLine::command_line() ]; #~ scalar <>; sleep 10;

        But the results were disappointing, no unicode

        [ "utf-filedir\\kebab\\cevap.txt", "utf-filedir\\kebab\\ra\x9Enjic.txt", "utf-filedir\\kebab\\???????.txt", "utf-filedir\\kebab\\??????.txt", "utf-filedir\\kebab\\?????.txt", "utf-filedir\\kebab\\????.txt", "utf-filedir\\kebab\\ra\x9Enjic", "utf-filedir\\kebab\\cevap.txt", ] [ "utf-filedir\\kebab\\cevap.txt", "utf-filedir\\kebab\\ra\x9Enjic.txt", "utf-filedir\\kebab\\???????.txt", "utf-filedir\\kebab\\??????.txt", "utf-filedir\\kebab\\?????.txt", "utf-filedir\\kebab\\????.txt", "utf-filedir\\kebab\\ra\x9Enjic", "utf-filedir\\kebab\\cevap.txt", ] "utf-filedir\\a.exe utf-filedir\\kebab\\cevap.txt utf-filedir\\kebab\\ +raznjic.txt utf-filedir\\kebab\\???????.txt utf-filedir\\kebab\\????? +?.txt utf-filedir\\kebab\\?????.txt utf-filedir\\kebab\\????.txt utf- +filedir\\kebab\\raznjic utf-filedir\\kebab\\cevap.txt" [ "utf-filedir\\kebab\\cevap.txt", "utf-filedir\\kebab\\ra\x9Enjic.txt", "utf-filedir/kebab/RANJI~1.TXT", "utf-filedir/kebab/0CA1~1.TXT", "utf-filedir/kebab/35AA~1.TXT", "utf-filedir/kebab/531D~1.TXT", "utf-filedir/kebab/DD0B~1.TXT", "utf-filedir/kebab/EVAP~1.TXT", "utf-filedir/kebab/cevap.txt", "utf-filedir\\kebab\\????.txt", "utf-filedir\\kebab\\ra\x9Enjic", "utf-filedir\\kebab\\cevap.txt", ] [ "utf-filedir\\a.exe utf-filedir\\kebab\\cevap.txt utf-filedir\\kebab +\\ra\x9Enjic.txt utf-filedir\\kebab\\???????.txt utf-filedir\\kebab\\ +??????.txt utf-filedir\\kebab\\?????.txt utf-filedir\\kebab\\????.txt + utf-filedir\\kebab\\ra\x9Enjic utf-filedir\\kebab\\cevap.txt", ]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990907]
help
Chatterbox?
[thezip]: Amazing speed and stealth in that one.
[GotToBTru]: You can't tunafish, but some seafood companies can tunafish. More fun with English.
[virtualsue]: a veterinarian told me to cut down on my cat's food. i said, when i do that she just catches more mice
[thezip]: My dogs are also excellent mousers, at least that's what they tell me.
[GotToBTru]: our beagle has dispatched 3 rabbits to the Great Hutch in the Sky since March.
[thezip]: I can always tell when the dogs have been mousing, as there is a concentric ring of mud around the end of their snouts when they do.
[thezip]: As for more physical evidence, that always seems to be missing somehow
[Rabbi Bob]: We have a Jack Russell: off the leash she is a torpedo against mice, rats, chipmunks and squirrels
[Rabbi Bob]: Doesn't eat them, just snaps, kills, drops and moves on.
[thezip]: Efficient, that one.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (15)
As of 2017-11-17 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (272 votes). Check out past polls.

    Notices?