in reply to Re: UTF8 error when using Net::SFTP::Foreign
in thread UTF8 error when using Net::SFTP::Foreign
When I have that stored as "test.pl" and do perl test.pl, the output I get is: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 ); }
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 utf8Of 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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: UTF8 error when using Net::SFTP::Foreign
by ikegami (Patriarch) on Feb 18, 2009 at 04:17 UTC |