in reply to Re^3: Character encoding in console in Windows
in thread Character encoding in console in Windows

Of course it's possible, you are probably misunderstanding me. When you drop in a file, the console displays its path, and then the script can take that as input.

So what my code does is:

1. tell the user to drag and drop a file in the console, wait for input via STDIN
2. user drags & drops file from file manager into console, the full filepath appears in the console, user presses enter
3. the script stores the string with the filepath in a variable, parses it, opens the file, magic happens

Pretty much all OSes have this functionality apart from Windows Vista (XP and Win7 have it, Vista is the only one that doesn't).

This is pretty much the default method for cd'ing into a directory for most people... you type "cd ", drag and drop a folder and press enter... it eliminates a hell of a lot of typing.
It works fine in my script in most scenarios, but not with accented characters on Windows.

BTW the same will often work with URLs, depending on what browser you have and which bit you're grabbing. If you grab a photo from an open webpage, the URL of the image should appear in the console, and you can often drag & drop favicons or links etc.

  • Comment on Re^4: Character encoding in console in Windows

Replies are listed 'Best First'.
Re^5: Character encoding in console in Windows
by BrowserUk (Patriarch) on Sep 11, 2010 at 20:28 UTC
    Pretty much all OSes have this functionality apart from Windows Vista

    I run Vista.

    (But I don't remember seeing this work in XP which I ran for years. But maybe I just never thought to try it?)

      Well, the whole drag-and-drop mystery has been cleared up, but there is no solution for the original issue. Can anyone help?

        As I cannot test this, and have no prior knowledge of it, I'm probably the wrong one to ask.

        However, my guess would be that you need to set STDIN to expect utf2le, in order to be able to read the unicode into perl.

        Once you have the unicode, you will need to use Win32::Unicode::File->open() in order to be able to open files with unicode names.

        But that is all speculation on my behalf. When ikegami drops by he'll be able to give you chapter and verse on the Unicode stuff. Just be patient.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.