we don't need to touch encoding for AnyEvent::IRC
[MQR.git] / scripts / mqr-xmpp-client.pl
index 646c42e..ba191c2 100755 (executable)
@@ -9,6 +9,7 @@ use AnyEvent::XMPP::Ext::Version;
 use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
 use AnyEvent::Redis;
 use Data::Dump qw(dump);
+use Encode;
 
 binmode STDOUT, ":utf8";
 
@@ -36,6 +37,7 @@ our $contacts;
 $sub->psubscribe( 'channel *', sub {
        my ( $message, $from ) = @_;
        return unless $from !~ m/\Q$jid\E/; # skip our messages
+       Encode::_utf8_on($message);
        warn "#Q<< ", dump( $from, $message );
        my ( undef, $channel, $user ) = split(/ /,$from,3);
 warn "# contacts ",dump($contacts);
@@ -63,6 +65,7 @@ $cl->reg_cb (
 warn "# contacts ",dump($contacts);
 
                my $channel = join(' ', 'channel', $msg->from);
+               Encode::_utf8_off($body);
                $pub->publish( $channel, $body );
                warn "#X<< ",dump($channel, $body);