A
A. Farber
Hello,
I have a multiplayer card game at http://preferans.de
The Flash client sends and reads UTF8 data
(prepended by 16-bit length to make
Flash's readUTF() function happy)
to the non-forking Perl server.
Everything works fine until someone with a russian name joins.
Then the Perl print displays his name as garbage
(but not russian garbage ;-) and when I save
that name into PostgreSQL (UTF8 database) it looks
like this: http://preferans.de/viewforum.php?f=5
So I've added a utf8::decode($name) for all user names.
This has fixed print outputs and Postgres, but I've got
Wide character in syswrite at /usr/libdata/perl5/i386-openbsd/5.10.0/
IO/Handle.pm line 459.
After reading
http://london.pm.org/pipermail/london.pm/Week-of-Mon-20071210/011804.html
I understand that I need to utf8::encode() the
data I'm syswriting back to the Flash client.
Here is my modified function:
sub enqueue {
my $child = shift;
my $data = shift;
my $fh = $child->{FH};
my $response = $child->{RESPONSE};
# flash.net.Socket.readUTF() expects 16-bit prefix in network
order
my $prefix = pack 'n', length $data;
# append to the end of the outgoing queue
push @{$response}, $prefix . utf8::encode($data);
}
Unfortunately I get the warning
Use of uninitialized value $data in length at Child.pm line 234.
Use of uninitialized value $data in concatenation (.) or string at
Child.pm line 237.
and everything stops working.
Does anybody know what is going wrong here?
My data is just an urlencoded data like "user0=Russian_name".
Regards
Alex
PS: I'm using OpenBSD 4.5 with:
p5-pgsql-1.9.0p0
postgresql-client-8.3.6
postgresql-server-8.3.6
vim-7.2.77-no_x11
and
This is perl, v5.10.0 built for i386-openbsd
And I connect from Windows using Putty and Vim
who both are capable to display/edit UTF8.
I have a multiplayer card game at http://preferans.de
The Flash client sends and reads UTF8 data
(prepended by 16-bit length to make
Flash's readUTF() function happy)
to the non-forking Perl server.
Everything works fine until someone with a russian name joins.
Then the Perl print displays his name as garbage
(but not russian garbage ;-) and when I save
that name into PostgreSQL (UTF8 database) it looks
like this: http://preferans.de/viewforum.php?f=5
So I've added a utf8::decode($name) for all user names.
This has fixed print outputs and Postgres, but I've got
Wide character in syswrite at /usr/libdata/perl5/i386-openbsd/5.10.0/
IO/Handle.pm line 459.
After reading
http://london.pm.org/pipermail/london.pm/Week-of-Mon-20071210/011804.html
I understand that I need to utf8::encode() the
data I'm syswriting back to the Flash client.
Here is my modified function:
sub enqueue {
my $child = shift;
my $data = shift;
my $fh = $child->{FH};
my $response = $child->{RESPONSE};
# flash.net.Socket.readUTF() expects 16-bit prefix in network
order
my $prefix = pack 'n', length $data;
# append to the end of the outgoing queue
push @{$response}, $prefix . utf8::encode($data);
}
Unfortunately I get the warning
Use of uninitialized value $data in length at Child.pm line 234.
Use of uninitialized value $data in concatenation (.) or string at
Child.pm line 237.
and everything stops working.
Does anybody know what is going wrong here?
My data is just an urlencoded data like "user0=Russian_name".
Regards
Alex
PS: I'm using OpenBSD 4.5 with:
p5-pgsql-1.9.0p0
postgresql-client-8.3.6
postgresql-server-8.3.6
vim-7.2.77-no_x11
and
This is perl, v5.10.0 built for i386-openbsd
And I connect from Windows using Putty and Vim
who both are capable to display/edit UTF8.