Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > decoding utf8

Reply
Thread Tools

decoding utf8

 
 
timnels@gmail.com
Guest
Posts: n/a
 
      09-22-2005
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 (12
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.

 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      09-23-2005
wrote:
> 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 (12
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
given char* utf8, how to read unicode line by line, and output utf8 gry C++ 2 03-13-2012 04:32 AM
Combining & Decoding video. Aido Firefox 6 10-30-2005 03:19 AM
decoding utf8 timnels@gmail.com Java 3 09-29-2005 01:44 PM
Want Yenc decoding - Netscape 7.2 or Other? murman Firefox 1 09-03-2004 07:47 PM
Conbine and decoding in Thunderbird Joebee Firefox 0 09-24-2003 12:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57