I think ikegami's point is that the byte sequence won't change if all you do is turn off the utf8 flag, and it seems like that is the only issue that Net::SFTP::Foreign is having with the OP data. Consider:
use strict; use warnings; main(); sub main { my $test = "\x{0414}"; # unicode cyrillic "capital letter de" printf( "character length: %d\n", length( $test )); check_string( $test, 1 ); # this call causes "Wide character in print" warning, but outpu +t is ok utf8::encode( $test ); printf( "byte length: %d\n", length( $test )); check_string( $test, 2 ); # no warning from this call } sub check_string { my ( $str, $num ) = @_; my $status = ( utf8::is_utf8( $str )) ? 'utf8' : 'not utf8'; printf( " %d -- check_string: input %s is %s\n", $num, $str, $stat +us ); }
When I have that stored as "test.pl" and do perl test.pl, the output I get is:
character length: 1
Wide character in print at /tmp/test-bytes.pl line 21.
 1 -- check_string: input Д is utf8
byte length: 2
 2 -- check_string: input Д is not utf8
Of course, if I run that with perl -CS test.pl (to do the same thing as  binmode STDOUT, ":utf8";), the "Wide character in print" warning goes away, but then when check_string() gets called the second time, perl forces an "upgrade" of the two bytes that make up the "unflagged" cyrillic character, producing faulty output (four non-ascii bytes instead of two) - but that's a separate issue.

In reply to Re^2: UTF8 error when using Net::SFTP::Foreign by graff
in thread UTF8 error when using Net::SFTP::Foreign by deadpickle

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.