Can't fix that. It's not an error in the program.
When I get filenames, I have to use them in the byte representation, instead of utf8, because, conversion to utf8 can brake some filenames.
Mostly, everything else needs to be in utf8.
I use file system path modules in order to manipulate the dirs and files names, etc.
When I print those path names to the screen, if they are not decoded, they show garbage in non-latin letters. Those modules, in certain cases, after manipulating the path names, keep strings in byte representation, but set the variable's utf8 flag on, which makes the variable contents, being represented in bytes with utf8 standard routine checking, thinking, that it's utf8 already.
I have a subroutine, I've wrote for outputting stuff to stdout. I do not use print directly, because my subroutine handles everything automatically, so that I can use one program to use in CGI, terminal STDOUT and GUI without rewriting.
I need a way in that subroutine to detect, if the variable, that it recieved is utf8 or a byte string.
I've used to use: use encoding 'utf8', STDOUT => 'utf8';, and it worked automatically, but now, since perl's the version 5.20, or something, the encoding pragma is finally deprecated, so I have to think of an other way to solve this encoding issue.

In reply to Re^2: utf8 char or binary string detection by igoryonya
in thread utf8 char or binary string detection by igoryonya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.