× 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.



    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
>







As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.