decoding utf8

Discussion in 'Perl Misc' started by timnels@gmail.com, Sep 22, 2005.

  1. Guest

    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.
     
    , Sep 22, 2005
    #1
    1. Advertising

  2. Joe Smith Guest

    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 (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
     
    Joe Smith, Sep 23, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ouadid abdelkarim
    Replies:
    0
    Views:
    2,044
    ouadid abdelkarim
    Jul 10, 2003
  2. Laurent Pinchart

    Address decoding

    Laurent Pinchart, Apr 11, 2004, in forum: VHDL
    Replies:
    3
    Views:
    6,436
    Jim Lewis
    Apr 12, 2004
  3. Bjorn Jensen
    Replies:
    2
    Views:
    838
    Bjorn Jensen
    Mar 22, 2005
  4. decoding utf8

    , Sep 22, 2005, in forum: Java
    Replies:
    3
    Views:
    3,147
    jan V
    Sep 29, 2005
  5. gry
    Replies:
    2
    Views:
    823
    Alf P. Steinbach
    Mar 13, 2012
Loading...

Share This Page