Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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

by exilepanda (Pilgrim)
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...

Replies are listed 'Best First'.
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

      #!/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. 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990913]
and a log crumbles through the grate...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-03-23 19:00 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (296 votes). Check out past polls.