× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 09/02/2002 at 12:39:05 PM, java400-l-admin@midrange.com wrote:
Remember the text is received into a byte array.  If that happens to be
in ASCII, which is probably is, and the program says to convert that to
Unicode but interpret the bytes as if they're EBCDIC, then the
conversion will not be properly performed.  The statement

  String myString = new String(socketByteArray)

will assume that the byte array contains ASCII on a non-iSeries machine
but EBCDIC on an iSeries machine.
--- end of excerpt ---

No, that's not true.
That would be a really non-portable way to deal with Java on an iSeries
machine.
Java usually interfaces to the native machine in unicode or ASCII just like
it does on other systems.
I.e. if you write an output file or output socket stream in Java, that data
by default should be in ASCII.

Note that the problem then typically comes in when native iSeries programs
send binary data (EBCDIC) to a Java opened streams (which expect them to be
ASCII). There are some tricks that occur in some circumstances (which I
don't exactly recall), in which the data encoding is changed upon
read/write (i.e. think standard I/O)


Run this example:
public class ByteEncoding {
   public static void main(String args[]) {
      byte     asciiHello[] = new byte[]{ (byte)0x48, (byte)0x65,
(byte)0x6c, (byte)0x6c, (byte)0x6f };
      byte     ebcdicHello[] = new byte[]{ (byte)0xC8, (byte)0x85,
(byte)0x93, (byte)0x93, (byte)0x96 }; // CCSID 37

      String   sAscii = new String(asciiHello);
      String   sEbcdic = new String(ebcdicHello);
      System.out.print("Ascii String: ");
      System.out.println(sAscii);
      System.out.print("Ebcdic String: ");
      System.out.println(sEbcdic);
   }
}


You'll see this output on your Windows machine:
Ascii String: Hello
Ebcdic String: ╚àôôû

You'll see this output on your iSeries machine:
 Ascii String: Hello
 Ebcdic String: È

Note that the ASCII array was 'correctly' converted to a string, while the
EBCDIC one was not.



"The stuff we call "software" is not like anything that human society
  is used to thinking about. Software is something like a machine, and
  something like mathematics, and something like language, and
  something like thought, and art, and information...
  but software is not in fact any of those other things."
Bruce Sterling - The Hacker Crackdown

Fred A. Kulack - IBM eServer iSeries - Enterprise Application Solutions
ERP, Java DB2 access, Jdbc, JTA, etc...
IBM in Rochester, MN  (Phone: 507.253.5982   T/L 553-5982)
mailto:kulack@us.ibm.com   Personal: mailto:kulack@magnaspeed.net
AIM Home:FKulack  AIM Work:FKulackWrk
MSN Work: fakulack@hotmail.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.