Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 : )_~

Replies are listed 'Best First'.
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?
[ambrus]: As for TeX, I'm not trying to discourage anyone from writing carefully beautifully typeset documents, in maths or outside. But most people aren't willing to do that, and will spend only little time about the formatting,
[ambrus]: and try to leave everything else to automated systems without checking how what they write came out format-wise, and for those people, discounting the part about journals with a specific format above,
[ambrus]: just blindly recommending to use LaTeX is a bad idea now.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-09-26 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?