Re: Binary to ASCII Question
From: Steve W. Jackson (stevewjackson_at_charter.net)
Date: 10/23/03
- Next message: Mike: "accessing a jTable problem"
- Previous message: Steve W. Jackson: "Re: Controlling where JDialog opens"
- In reply to: dog: "Binary to ASCII Question"
- Next in thread: Dale King: "Re: Binary to ASCII Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Oct 2003 16:33:33 -0500
In article <3f983d89$1_2@newspeer2.tds.net>,
"dog" <dawgwannabe@yahoo.com> wrote:
>:Binary to ascii Question
>:
>:I pick a JPG a.jpg
>:
>:I read in it using ServletInputStream to a byte[] array
>:
>:bytes are, of course, signed one byte things
>:So if you got through the array you get int values between -127 and 127
>:
>:If you say
>:
>:String s = new String(byteArray)
>:char[] x = s.toCharArray();
>:
>:And then go through that away you get int values way above 256
>:
>:Why?
>:
>:Really just wondering. I would think it would translate each byte to the
>:unicode equal which is what I am trying to do. Okay that didn't work, but
>:what did it do? Anyeasy way to go from a JPG to unicode?
>:Do I add 128 to all the byte value of just knock of the sign? Or niether?
Have you read the API docs on this? You'll notice that the String
constructor that accepts a byte array specifically states that it
constructs a new String by decoding the specified array of bytes using
the platform's default charset. So if that array of bytes didn't come
from Unicode or other actual character data, then you probably shouldn't
logically expect the resulting String to have any meaningful content.
= Steve =
-- Steve W. Jackson Montgomery, Alabama
- Next message: Mike: "accessing a jTable problem"
- Previous message: Steve W. Jackson: "Re: Controlling where JDialog opens"
- In reply to: dog: "Binary to ASCII Question"
- Next in thread: Dale King: "Re: Binary to ASCII Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|