Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Perl / FileFind or ...

by Festus Hagen (Novice)
on Nov 27, 2012 at 21:56 UTC ( #1005932=note: print w/ replies, xml ) Need Help??


in reply to Perl / FileFind or ...

Yea Tom, that be exactly the issue.

Right or wrong, I have tried utf8, unicode and many other things found while searching, to no avail.

Guess I just don't get it, Why such a simple thing is so difficult.

-Enjoy
fh : )_~


Comment on Re: Perl / FileFind or ...
Re^2: Perl / FileFind or ...
by Anonymous Monk on Nov 27, 2012 at 22:51 UTC

    Yea Tom, that be exactly the issue.

    Since PerlMonks offers threaded discussions, it is important to reply to the correct node by clicking the [reply] alongside the node of interest

    Guess I just don't get it, Why such a simple thing is so difficult.

    Decode the input, Encode the output, read perlunitut: Unicode in Perl#I/O flow (the actual 5 minute tutorial) and learn about your shell

    $ chcp Active code page: 437 $ echo > "da-MötleyCrüe" $ dir /b "da-*" da-MötleyCrüe $ dir /b "da-*" | perl -MData::Dump -e " dd[<>] " ["da-M\x94tleyCr\x81e\n"] $ perl -MData::Dump -e " dd[ glob q/da-*/ ] " ["da-M\xF6tleyCr\xFCe"]

    Single byte encoding can be hard to guess

    $ perl -MEncode::Detective=detect -le " die detect( glob q/da-*/ ) " windows-1252 at -e line 1. $ perl -MEncode::Guess -e " die guess_encoding( glob q/da-*/ ) " No appropriate encodings found! at -e line 1. $ dir /b "da-*" | perl -MEncode::Detective=detect -e " $f = <>; die de +tect($f ) " Died at -e line 1, <> line 1. $ dir /b "da-*" | perl -MEncode::Guess -e " $f = <>; die guess_encodin +g($f ) " No appropriate encodings found! at -e line 1, <> line 1. $ dir /b "da-*" | perl -MEncode::Guess -e " $f = <>; die guess_encodin +g($f , q/cp437/) " Encode::XS=SCALAR(0x9a622c) $ dir /b "da-*" | perl -MEncode::Guess -e " $f = <>; die guess_encodin +g($f , q/cp437/)->name " cp437 at -e line 1, <> line 1.

    But once you know, just binmode
    $ perl -le " print for glob q/da-*/ "
    da-M÷tleyCrⁿe

    $ perl -le " binmode STDOUT , q/:encoding(cp437)/; print for glob q/da-*/ "
    da-MötleyCrüe

    $ perl -Mopen=:std,encoding(cp437) -le " print for glob q/da-*/ "
    da-MötleyCrüe

    $ perl -MEncode::Locale -le " binmode STDOUT, q{encoding(console_out)}; print for glob q/da-*/ "
    da-MötleyCrüe

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2015-07-03 22:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls