decoding utf8

T

timnels

I've got a J2ME application that is doing a writeUTF() of a byte array
that I need to decode and store in a flat file (it's a jpeg) from my
perl socket application. I can't seem to find a way to have Perl
decode it into it's byte representation.

As a test I put a byte array of just control-A's on the wire using
writeUTF. The length of the scalar I get in Perl is exactly twice (128)
as I sent (64). I've tried doing: $decoded =
Encode::decode_utf8($netbuf) and it doesn't convert the data at all.
Obviously, I must be missing how Perl handles a scalar that contains
UTF-8 data.

Can someone point me in a direction? Thanks.
 
J

Joe Smith

I've got a J2ME application that is doing a writeUTF() of a byte array
that I need to decode and store in a flat file (it's a jpeg) from my
perl socket application. I can't seem to find a way to have Perl
decode it into it's byte representation.

As a test I put a byte array of just control-A's on the wire using
writeUTF. The length of the scalar I get in Perl is exactly twice (128)
as I sent (64).

If you start with "\001\002" and get "\000\001\000\002" or
"\001\000\002\000" then you're probably dealing with UTF-16.
It would be better to test with "\177\200\201" ("\x7f\x80\x81")
instead, to see how your datastream handles the high bit.

-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,052
Latest member
KetoBeez

Latest Threads

Top