in reply to Re^3: opening accented file names
in thread opening accented file names

(Sorry, I can't follow your session log because there are too many things going on in it at once. It's too dense and complicated.)

Sorry, let me simplify it.

This is in a completely new session as identified by the banner at the top. Everything you see in the session was typed manually, not copy&pasted. (This is important!). As I stated above, I am typing the 'ó' using AltGr-o:

Microsoft Windows [Version 6.0.6001] Copyright (c) 2006 Microsoft Corporation. All rights reserved. c:\>dir ac*/b File Not Found c:\>chcp 65001 Active code page: 65001 c:\>echo this is the contents of acentó.dat >acentó.dat c:\>dir ac*/b acentó.dat c:\>perl -pe1 acentó.dat this is the contents of acentó.dat c:\>

The reason typing rather than cutting and pasting is important, is because the character code that sits behind the ó glyph will vary from codepage to code page.

Hence, note the glyph displayed when the contents of a file created under cp437 are displayed under cp65001. On screen, prior to cutting and pasting to perlmonks, that � character is displayed as the typical 'open box' glyph.

c:\>chcp 437 Active code page: 437 c:\>echo this is the contents of acentó.dat > acentó.dat c:\>dir /b ac* acentó.dat c:\>perl -pe1 acentó.dat this is the contents of acentó.dat c:\>chcp 65001 Active code page: 65001 c:\>dir /b ac* acentó.dat c:\>perl -pe1 acentó.dat this is the contents of acent�.dat

So, your inclusion of the codepages confuses rather than clarifies.


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.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^5: opening accented file names
by Jim (Curate) on Nov 12, 2010 at 05:39 UTC

    You're mistaken. My inclusion of the CHCP command was essential to understanding that the glyph displayed in the Windows Command Prompt is dependent on the active code page. It is, I assure you. (And I've proved it already.) That's really all there is to it.

    Your attempts to confuse matters with what's inside the file are meaningless and confusing here. We're examining the file name, not the file contents, and what happens when ActivePerl reads the file name.

      Unless my eyes are deceiving me, no matter which codepage I use to create the file, or which I use to subsequently view that file, the glyph appears correct.

      Microsoft Windows [Version 6.0.6001] Copyright (c) 2006 Microsoft Corporation. All rights reserved. c:\>chcp Active code page: 850 c:\>dir /b ac* acentó.dat c:\>chcp 437 Active code page: 437 c:\>dir /b ac* acentó.dat c:\>chcp 65001 Active code page: 65001 c:\>dir /b ac* acentó.dat c:\>chcp 65000 Active code page: 65000 c:\>dir /b ac* acentó.dat Microsoft Windows [Version 6.0.6001] Copyright (c) 2006 Microsoft Corporation. All rights reserved. c:\>del ac* c:\>chcp 437 Active code page: 437 c:\>echo fred > acentó.txt c:\>dir /b ac* acentó.txt c:\>chcp 850 Active code page: 850 c:\>dir /b ac* acentó.txt c:\>chcp 65001 Active code page: 65001 c:\>dir /b ac* acentó.txt c:\>chcp 65000 Active code page: 65000 c:\>dir /b ac* acentó.txt c:\>del ac* c:\>chcp 65001 Active code page: 65001 c:\>echo fred > acentó.txt c:\>chcp 65000 Active code page: 65000 c:\>dir /b ac* acentó.txt c:\>chcp 850 Active code page: 850 c:\>dir /b ac* acentó.txt c:\>chcp 437 Active code page: 437 c:\>dir /b ac* acentó.txt c:\>

      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.

        I see exactly the same output when I run those same commands. This demonstrates the DIR command properly outputs and displays a Latin small letter o with an acute accent regardless of the active code page (so long as ó is in the repetoire of characters of the code page), which is terrific, and good to know. But this is PerlMonks, not DirMonks. ;-)

        Now run my Perl script as I did with the code page set to 437, 850, 1252, 65001, etc. Then come back and tell me if you still think I was "confusing things by mentioning chcp" and that "[i]t isn't necessary." I wasn't, and it is.

        The important and germane point here is that, unlike what DIR does, ActivePerl for Windows prints whatever the glyph is for byte \xF3 in whatever the active code page is.