[jdev] Ok, here's my tiny little Perl script

John Talbot jtalbot at proionta.gr
Thu Sep 29 09:31:25 CDT 2005


You can copy/paste it to see that it does indeed produce wrong output 
(at least on jabberd 1.4 & Perl 5.8.4 which I use, though I doubt 
there's something wrong with these versions)

I challenge anyone to find a programming error in this code.



--------------------------

#!/usr/bin/perl -w

use Net::Jabber;

########################################################
# EDIT THE FOLLOWING VALUES TO MATCH YOUR OWN SERVER'S #
########################################################
my $HOSTNAME = '192.168.1.100';
my $USERNAME = 'admin';
my $PASSWORD = 'password';
my $PORT = 5222;
my $RESOURCE = 'bot';
########################################################


my $c = new Net::Jabber::Client();

my $status = $c->Connect( hostname => $HOSTNAME, port => $PORT );
die unless $status;

my @result = $c->AuthSend( username => $USERNAME, password => $PASSWORD, 
resource => $RESOURCE );
die if $result[0] ne 'ok';

my $m = new Net::Jabber::Message();

my $body = 'Γεια σου';

$m->SetMessage(to => "$HOSTNAME/announce/motd",
               body => $body);

$c->Send($m);



Tijl Houtbeckers wrote:
> The answer is simple; Use UTF-8, and use it correctly.
>
> If it goes wrong, then either something in your code, or in 
> Net::Jabber or Perl is going wrong too.
> While neither Net:Jabber nor Perl has a very brilliant history in 
> supporting unicode, I think by now both are mature enough to assume 
> (for now) the error is in your code. For the rest I'll leave this one 
> to the Perl experts though..




More information about the JDev mailing list