Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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

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

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990907]
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2018-05-27 14:17 GMT
Find Nodes?
    Voting Booth?