|
Joe and Joe,, If you're using CCSID 5026, the Java equivalent encoding value should be Cp930. CCSID hex ESID Base CP1 CP2 Java K Description 5026 13a2 mbcs-ebcdic 930 290 + 300 Cp930 I Japan EBCDIC 5035 13ab mbcs-ebcdic 939 1027 + 300 Cp939 I Japan EBCDIC a side note on this, Cp943c, Cp943, MS932 and SJIS may have different mappings to Unicode characters, so if you have any problems converting certain Japanese characters in Java, I suggest refering to this url for selecting the correct mapping. http://www.ingrid.org/java/i18n/encoding/ja-conv.html (yes, its in Japanese...) Regards, Eiichi -----Original Message----- From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joe Sam Shirah Sent: Wednesday, January 21, 2004 3:55 PM To: Java Programming on and around the iSeries / AS400 Subject: Re: DBCS to Shift-JIS Hi Joe, I saw eiichi's reply and I expect it to be more definitive than mine, but I already had most of this written and maybe some of the info will help. I also ended up being puzzled by your question. I'll explain in a minute. Internally in Java, all String data is in ( what the VM thinks is ) Unicode. The normal way to convert bytes in one encoding to a String in Unicode is: String S1 = new String( byte[] bytes, String charsetName ); The program uses the String as Unicode until output time. If you just write the data, it goes to the system default encoding from the Unicode value. If it should not be the default, then you either use a file write with a specified encoding or use String.getBytes( String charsetName ) to get bytes in the specified encoding. In what may be good news for you, the "IBM Developer Kit for Java" at http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/rzaha/rzaha.pdf under "Java character encodings" starting on page 43, shows that CCSID 943 is equivalent to encoding Cp943 and CCSID 5026 is equivalent to Cp943C. So, if your data came from a file, you could read it in as Cp943 and write it out as Cp943C. That's the same method as eiichi's code except for the encoding values. Here's where I'm puzzled. The data you posted is not a Java byte array. The reason is that Java bytes range in value from -128 to +127; you have a value of F9 ( 249 ), so that can't work. The second part is, and my understanding of the encoding algorithms is limited here, so please correct: If we look at your data as non-Java bytes at 8 bits that can go to a value of 255, then it appears to me to amount to four double byte characters. I don't understand how you could get to only three characters in Shift-JIS. HTH, Joe Sam Joe Sam Shirah - http://www.conceptgo.com conceptGO - Consulting/Development/Outsourcing Java Filter Forum: http://www.ibm.com/developerworks/java/ Just the JDBC FAQs: http://www.jguru.com/faq/JDBC Going International? http://www.jguru.com/faq/I18N Que Java400? http://www.jguru.com/faq/Java400 ----- Original Message ----- From: "Joe Pluta" <joepluta@xxxxxxxxxxxxxxxxx> To: "'Java Programming on and around the iSeries / AS400'" <java400-l@xxxxxxxxxxxx> Sent: Tuesday, January 20, 2004 12:21 PM Subject: DBCS to Shift-JIS > Is there an easy way to take EBCDIC DBCS data (CCSID 5026) and convert > it to ASCII Shift-JIS (CCSID 943)? Will the AS400Text object help me > do this? Let's say I have an array of bytes with the EBCDIC data in > it. What's the easiest way to convert this to a String containing > Shift-JIS data? > > byte[] ccsid5026 = new byte[] > { x'0e', x'45', x'a0', x'47', x'9a', '45', x'f9', x'0f' }; > > And I want to get: > > String jisdata; > > With the following hex values: x'8d87', x'8cbe', x'9774' > > Joe > _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.