in reply to Re^2: UTF8 error when using Net::SFTP::Foreign
in thread UTF8 error when using Net::SFTP::Foreign

Try finding out if the flag is on for a good reason
I don't see how that's relevant.

Well, it's relevant insofar as the module - as it is - would abort if the flag is on, so finding out the reason for it being on might be a first step to better understanding one's own code, and for taking appropriate measures.

For example, in the following (contrived) situation

my $s = "hello"; my $u = "\x{7777}"; print "utf8 flag ", (utf8::is_utf8($s) ? "on":"off"), "\n"; # off $s .= $u; # do something which upgrades $s $s = substr($s, 0, 5); # get back the orig. "hello" print "utf8 flag ", (utf8::is_utf8($s) ? "on":"off"), "\n"; # on - $s +ftp->write(...) would abort

I'd say the flag is on "for no good reason", because the content is exactly the same as before manipulating $s (i.e. "hello"), and all characters occurring can be represented in plain ASCII.

OTOH, if the data actually would contain unicode characters that cannot be represented in ASCII (or some legacy encoding like Latin-1, etc., for that matter), the flag would be on "for a good reason", in case the data needs to be treated in a character-based fashion.

Whether the latter is the case with Net::SFTP::Foreign::write(), I simply don't know.  I didn't check what the author's specific reasons for not allowing UTF-8 might have been — as a first approximation, I tend to assume that module authors know what they're doing.

Replies are listed 'Best First'.
Re^4: UTF8 error when using Net::SFTP::Foreign
by ikegami (Patriarch) on Feb 18, 2009 at 03:59 UTC

    I'd say the flag is on "for no good reason", because the content is exactly the same as before manipulating $s (i.e. "hello"), and all characters occurring can be represented in plain ASCII.

    What's gained by knowing that?

    If the flag is on for no good reason, encode the text!
    If the flag is on for a good reason, encode the text!

      A third option (in addition to encoding or downgrading - as you've mentioned) could've been to simply fix the code that inadvertendly upgrades $coords...  as those coordinates appear to be simple numbers, I wouldn't know why unicode would need to play a role at all here.  That's why I got the impression that something unintentional might be going on in the OP's code...