in reply to Re: Character encoding in console in Windows
in thread Character encoding in console in Windows
If you're entering the file name by dragging and dropping, Windows should be encoding them using the console's code page, which means it's already properly encoded for use by open(). Don't do any decoding, and it should work.
Drag&drop would indeed be sufficient for me, although I'm not sure if there's any difference between typing a path in the console and having it pasted in with drag & drop. Either way, I certainly don't need @ARGV filename input at all.
You say drag and drop should work with plain old open(), but this is exactly what I originally tried and it failed, hence this tread. To make things clear, here's a simplified script showing what I do. It doesn't even parse the file name for path/filename/extension, it just strips whitespace and quotes and tests if the perl script can find the file.
#!/usr/bin/perl use strict; use warnings; print "Drop input file in console\n"; chomp (my $file = <STDIN>); $file =~ s/ *["']?([^"']*)["']? *$/$1/; # strip whitespace and +quotes if (-e "$file") {print "\nFile found, everything is fine.\nFile:>$file +<"} else {print "\nOoops, file not found.\nFile: >$file<"} <STDIN>;
Enter file path> í.txt $qfn="\241.txt" open í.txt: No such file or directory
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Character encoding in console in Windows
by ikegami (Patriarch) on Sep 16, 2010 at 06:41 UTC | |
by BrowserUk (Patriarch) on Sep 16, 2010 at 07:15 UTC | |
by ikegami (Patriarch) on Sep 16, 2010 at 13:23 UTC | |
by elef (Friar) on Sep 16, 2010 at 18:16 UTC | |
by ikegami (Patriarch) on Sep 18, 2010 at 01:49 UTC | |
by elef (Friar) on Sep 18, 2010 at 08:16 UTC | |
|
Re^3: Character encoding in console in Windows
by ikegami (Patriarch) on Sep 15, 2010 at 20:27 UTC |