Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: How can I get a Unicode @ARGV?

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


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

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...


Comment on Re^2: How can I get a Unicode @ARGV?
Re^3: How can I get a Unicode @ARGV?
by Anonymous Monk on Aug 31, 2012 at 08:27 UTC

    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", ]

        Inspired from your test result, I am really wondering if that's the encoding problem or if the argv actually turned into ANSI before pipe to my perl script...

        I've wrote a little more in reply to a upper thread. http://www.perlmonks.org/?node_id=991005 Do you think this can mean something ?

        Though, thank you very much for the help test! =)

        Win32::CommandLine doesn't actually use unicode calls, you need to compile it with

        #define UNICODE #define _UNICODE

        Then it'll probably work

        Although it should probably use GetCommandLineW explicitly

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990913]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2014-07-23 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (136 votes), past polls