Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^5: Windows NTFS UTF-16LE File-Operations

by repellent (Priest)
on Feb 21, 2012 at 00:29 UTC ( #955194=note: print w/replies, xml ) Need Help??

in reply to Re^4: Windows NTFS UTF-16LE File-Operations
in thread Windows NTFS UTF-16LE File-Operations

You need to encode back to octets the return of Win32::GetLongPathName(), because say is printing out octets. Win32::FindFile is most likely doing that for you already.

Which encoding you choose should depend on what your console expects (to be able to redisplay the characters).

perl -MEncode -E "say encode( 'UTF-8', Win32::GetLongPathName( $_ ) ) +for glob '*'"

If 'UTF-8' doesn't work out, choose another encoding that works well with your console. Bear in mind that the UTF-8 encoding may be fine as-is, and that the console just needs better fonts (which is not your case, because I infer that you can see the characters displayed properly using Win32::FindFile).

Replies are listed 'Best First'.
Re^6: Windows NTFS UTF-16LE File-Operations
by BrowserUk (Pope) on Feb 21, 2012 at 00:53 UTC

    Yes. That seems to work. I thought that -C0 would take care of that for me...I'm just very glad that I don't have to deal with this crap!

    \test\junk>perl -C0 -E"say Win32::GetLongPathName( $_ ) for glob '*'"
    Wide character in print at -e line 1.

    C:\test\junk>perl -MEncode -E "say encode('UTF-8', Win32::GetLongPathName( $_ ) ) for glob '*'"


    12/11/2010 05:58 7 acentó.txt
    20/11/2010 09:46 <DIR> ελληνικά

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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.

    The start of some sanity?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://955194]
[Corion]: choroba: Ooooh - I didn't think of that! I write my presentations as POD and if it "roughly" looks like Perl code, I should also syntax-check that...
[haukex]: Yes sorry I don't run them all the time, my POD tests are only run as author tests (and are excluded when I'm using Devel::Cover)
[Corion]: choroba: Hmm - no, I keep the snippets inline, but as my framework also has support for capturing output etc., maybe I should do the same...
[Corion]: haukex: Yes, that approach is sane, and it heals the fragility of Pod parsers in a nice way while still syntax-checking stuff
[choroba]: Unfortunately, none of it is online
[haukex]: I figured that POD tests make sense, but only as author tests
[choroba]: I mean, the slides are, but not the makefile with scripts to create them
[Corion]: haukex: I've only now arrived at that revelation ;)
[Corion]: choroba: I use spod5, which also has that support, and also implements its own kinda-make stuff
[haukex]: But that module I just linked to assumes that most verbatim blocks are runnable code, I have other modules where that's not the case, so there I just copy-and-paste the synopsis into the author tests...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2017-02-27 12:27 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.