in reply to Re^2: utf8 "\xB7" does not map to Unicode at /usr/local/bin/бибс/об‰ line 112.
in thread utf8 "\xB7" does not map to Unicode at /usr/local/bin/бибс/об‰ line 112.

"find /usr/local/bin -type f >/dev/null"

Of course this will produce no data because you are directing the output to /dev/null. What happens if you remove the output direction and instead just use find /usr/local/bin -type f ?

  • Comment on Re^3: utf8 "\xB7" does not map to Unicode at /usr/local/bin/бибс/об‰ line 112.
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: utf8 "\xB7" does not map to Unicode at /usr/local/bin/бибс/об‰ line 112.
by nikolay (Beadle) on Nov 07, 2015 at 01:48 UTC

    I will answer by example.

    open( $vrm, "|-:utf8", "/usr/bin/find $put -$tip $kriteriy" ) or die " +Can't run find: $!\n"; while( <$vrm> ){ push @svitok, $_; } print "ZNAK\n"; print "\n>$svitok[0]<\n"; exit;

    Gives me this:

    ZNAK Use of uninitialized value $svitok[0] in concatenation (.) or string a +t /usr/local/src/исп/бибс/об&#137; line 122. ./svitok1 ./svitok2 ./svitok3 ><

    So:

    1. >/dev/null only outputs not to terminal -- array remains the same -- and i want to output nothing to terminal.

    2. Array is not filled.

    3. Strange, but ZNAK mark is outputted *before* output of find though in the code it stands (executed) *after* find. Why?

    I think of qx operator -- is there a way that PERL will continue the operator execution -- regardless the encodings present in its output?

    Thank you for participation very much!

      Looking specifically at this snippet: Is the "open" statement the very first line of your script? (In other words, is the output that you showed based on running a script that contained exactly those 6 lines of code and nothing else?) Of course, I expect that you would have at least assigned values to $put, $tip and $kriteriy. (But maybe these values are not what they should be in order for "find" to work the way you expect?)

      In any case, I suspect that you didn't include the "binmode" statements that I recommended in my early reply -- or if you did, then your file names are not encoded the way you think they are.

      Some other points:

      • If you don't want any output to go to your terminal, then you should redirect STDOUT and STDERR to output files on the command line when you run your script.
      • The output you showed did not come from the code you posted here. The best way to get help is to post a minimal BUT COMPLETE script, together with the output created BY THAT PARTICULAR complete script.
      • There's nothing strange about "ZNAK" showing up first in the output, because that is the first thing to be printed by your code. The output of the "find" command is being treated as input to your script, which is read via the "$vrm" file handle.
      As for using the "qx" operator, that's certainly an option (instead of using the pipeline "open") - you just have to make sure that you Encode::decode the string returned by "qx", so that perl can treat it properly as utf8 data.

        Hello. Concerning the output on mistakes in Russian.

        I put to a script:

        use utf8::all; binmode STDOUT, 'utf8'; binmode STDERR, ":encoding(UTF-8)"; print 5

        -- to produce error because of absence of ; after print. PERL gave me on running:

        Can't modify constant item in scalar assignment at /япио/1.pl line 5, near "';"

        So, the binmode directives do not help.

        Thank you for your answers.