Reputation: 71
When reading from an IBMi system using a UserSpace object from JTOpen does the data get converted from EBCDIC to ASCII or does it remain in EBCDIC, using the UserSpace.read() methods.
If it does is there a way to tell it to not convert it or a different way to read that data. Or is there a way to just get the byte representation of the data. The below is what I see when I look at the userspace on the eye and in a perfect world getting that as a long string or in a byte array would be ideal.
24787779 5158B126 69675175 72536799
9BC7D489 85795158 B1276A96 A38580A3
A7676B37 25797288 A3A845D7 9996A674
74735496 99C7D389 8788A459 B2276866
96A38C83 A3969036 26797679 53A840D7
97D9D6E3 C5C3E3D6 D98794C9 C7C8E3E8
The userspace I am attempting to read uses CCSID 65535 if that matters.
Thank you.
Upvotes: 0
Views: 295
Reputation: 676
A *USRSPC object is a really just a named piece of memory. The data inside can contain any data you want. It could contain text encoded in EBCDIC, some ASCII code page, UTF-8, UTF-16, or whatever you like. It could contain an array of 4-byte integers or a matrix or a linked list of pointers or any other non-text data. It could contain a mix of text and non-text data: it's all up to what your application is writing in to it.
The UserSpace
JT400 API has no idea what the data is contained in the *USRSPC object is and so it just reads raw bytes. You'll need to read those bytes in to a byte array and use the CharConverter.byteArrayToString
method to convert it to a Java String object. Of course, you'll have to pass a valid text CCSID, not 65535.
Upvotes: 1
Reputation: 23793
CCSID 65535 tells the OS to consider the data as binary.
Thus, it will not be translated from EBCDIC to ASCII.
The right way to handle the translation, is to correctly tag the data with the right CCSID.
Otherwise take a look at the text conversion available in AS400Text class.
Lastly, with JDBC, there's a connection property you can set to force conversion of CCSID 65535. Not sure if there's something similar for the standard connection (AS400Text might be it).
Upvotes: 0