Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: UTF8 error when using Net::SFTP::Foreign

by deadpickle (Pilgrim)
on Feb 18, 2009 at 03:13 UTC ( [id://744629]=note: print w/replies, xml ) Need Help??


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

I'm trying to get this working. Not sure how to implament this but I added this just before the write statement:
utf8::downgrade( my $bytes_off = '' ); $bytes_off .= chr($coords) for 0..255; utf8::upgrade( my $bytes_on = '' ); $bytes_on .= chr($coords) for 0..255; # Downgrade variable on output to avoid false +positive. utf8::downgrade( my $from_off = $bytes_off ); utf8::downgrade( my $from_on = $bytes_on ); print("bytes are ", ($from_off eq $from_on ? ' +same' : 'diff'), "\n"); $sftp->write( $waytemp, $coords);
where $coords = 12,23. Now I get the error
Thread 2 terminated abnormally: Wide character in subroutine entry at + GRRUVI-v1. 43.pl line 1428.
that I have been hearing about.

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

    You mean you don't get Argument "12,23" isn't numeric in chr? I have very low tolerance for people don't help themselves by using use strict; use warnings;.

    That code snippet you are using was used to demonstrate that utf8::downgrade works regardless of the internal format of a string. It's not a solution to your problem. If anything, the other snippet would be more relevant since you have text.

    If $coords had contained bytes (already encoded text or packed/binary data, etc), the solution would have been utf8::downgrade.

    Since $coords contains text, the solution is Encode's encode.

    use Encode qw( encode ); $sftp->write( $waytemp, encode($enc, $coords) );

    Replace $enc with the encoding you desire to use.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://744629]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-03-28 18:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found