Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: treat files with umlauts (utf)

by hazylife (Monk)
on Apr 01, 2014 at 11:08 UTC ( [id://1080531]=note: print w/replies, xml ) Need Help??


in reply to Re: treat files with umlauts (utf)
in thread treat files with umlauts (utf)

So, I'm unable to reproduce your problem.
That's because your code is missing the two key ingredients:
use utf8; ... my $scandir = 'something with umlauts it it';

Replies are listed 'Best First'.
Re^3: treat files with umlauts (utf)
by kcott (Archbishop) on Apr 01, 2014 at 11:56 UTC
    "That's because your code is missing the two key ingredients:"

    No, it's not.

    "use utf8;"

    Neither my code nor the code the OP posted requires the utf8 pragma. See the following, from that documention, which it shows in bold-faced type:

    "Do not use this pragma for anything else than telling Perl that your script is written in UTF-8."
    "my $scandir = 'something with umlauts it it';"

    The OP does not say that $scandir contains umlauts. The only mention of umlauts by the OP is:

    "Given is a file which contains german umlauts in its name (e.g. 'Fehler für Projekt x.xls')"

    He says "file" and provides what would be resonable to assume is an MS Excel spreadsheet file. There's nothing about any directory whose name contains umlauts.

    -- Ken

      The OP does not say that $scandir contains umlauts.
      Neither my code nor the code the OP posted requires the utf8 pragma.
      True, but the OP did mention "a SLES Linux with UTF-8 support switched on", and, strictly speaking, use utf8 is not the only means of getting $scandir flagged as UTF-8:
      binmode(STDIN, ':encoding(UTF-8)'); chomp(my $scandir = <STDIN>); #OR $ perl -CS -e 'chomp(my $scandir = <STDIN>); ...' #OR $ perl -CA -e 'my $scandir = shift; ...' <dir>

        I really don't think you understand what the utf8 pragma does. Here's another quote from the documentation (first line of the description):

        "The use utf8 pragma tells the Perl parser to allow UTF-8 in the program text in the current lexical scope ..."

        It has nothing to do with the:

        • flagging variables ("getting $scandir flagged as UTF-8")
        • encoding of STDIN, STDOUT or STDERR ("perl -CS ...")
        • encoding of @ARGV elements ("perl -CA ...")

        Let me reiterate the quote I provided in my earlier post from the utf8 documentation:

        "Do not use this pragma for anything else than telling Perl that your script is written in UTF-8."

        It has nothing to do with data read into the script, data processed by the script, data generated by the script or data output by the script. It's only about the text used to write the script and how Perl should parse that source text.

        -- Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found