A
A. Farber
Hello,
I have a russian card game at
http://apps.facebook.com/video-preferans/
which I've recently moved from using urlencoded data
to XML data in UTF-8. Since then it often hangs
for the users and I suspect, that my subroutine:
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 . $data;
}
packs wrong number of bytes for cyrillic messages.
I'm using perl v5.10.0 at OpenBSD 4.5 and
"perldoc -tf length" suggests using
length(Encoding::encode_utf8(EXPR))
But when I put the line:
use Encode::Encoding;
....
my $prefix = pack 'n', length(Encoding::encode_utf8($data));
then it borks with
Undefined subroutine &Encoding::encode_utf8 called at Child.pm line
229.
Any help please?
Also I have to mention, that when users chat
in Russian, my server just passes their cyrillic
messages around (with sysread - poll - syswrite).
But for their cyrillic words in my program (I "use utf8;")
I have to call utf8::encode($cyrillic_word) before I can
write it away with syswrite or it would die ("wide char").
I've tried moving utf8::encode($data) into the
enqueue subroutine above but it doesn' allow me
(maybe because parts of $data are not utf8??)
Regards
Alex
I have a russian card game at
http://apps.facebook.com/video-preferans/
which I've recently moved from using urlencoded data
to XML data in UTF-8. Since then it often hangs
for the users and I suspect, that my subroutine:
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 . $data;
}
packs wrong number of bytes for cyrillic messages.
I'm using perl v5.10.0 at OpenBSD 4.5 and
"perldoc -tf length" suggests using
length(Encoding::encode_utf8(EXPR))
But when I put the line:
use Encode::Encoding;
....
my $prefix = pack 'n', length(Encoding::encode_utf8($data));
then it borks with
Undefined subroutine &Encoding::encode_utf8 called at Child.pm line
229.
Any help please?
Also I have to mention, that when users chat
in Russian, my server just passes their cyrillic
messages around (with sysread - poll - syswrite).
But for their cyrillic words in my program (I "use utf8;")
I have to call utf8::encode($cyrillic_word) before I can
write it away with syswrite or it would die ("wide char").
I've tried moving utf8::encode($data) into the
enqueue subroutine above but it doesn' allow me
(maybe because parts of $data are not utf8??)
Regards
Alex