EBCDIC To ASCII Conversion

1,064 views
Skip to first unread message

Shivam Purwar

unread,
Oct 9, 2017, 3:37:55 PM10/9/17
to jPOS Users


Hi Team,
I have Master Card (IPM )file which is in EBCDIC format .I am not able to read this file .If this is file available in ASCII (File data look like     ¢1644Ø)then I can read.
I am using java to read this file.I am unable to convert EBCDIC to ASCII.
Below is my code snip ,Please help me its urgent.

FileInputStream fis=new FileInputStream(new File("D:\\BinakNizwa files\\MasterCard_Sample_Format\\demo2.txt"));
int numericChar;
//InputStreamReader rdr = new InputStreamReader(new FileInputStream("D:\\BinakNizwa files\\MasterCard_Sample_Format\\demo2.txt"), java.nio.charset.Charset.forName("ibm500"));

byte b[]=new byte[4];
fis.read(b);// reading message type eg:-1644,1240
String str=new String(b,"CP037");//out put  &=&Ï  expected 1644
System.out.println(str);

below is my file data which is EBCDIC format.

סצפפ€            
Thanks ,
Shivam Purwar

Alejandro Revilla

unread,
Oct 9, 2017, 3:41:43 PM10/9/17
to jPOS Users
Read the bytes, use jPOS EBCDIC based field packagers to deal with it.

Good thing is it can be done using jPOS, as a matter of fact, I understand MasterCard uses jPOS to generate some of these daily IPM files.

If you have to deal with long records, you'll even have to create a special input stream implementation in order to swallow some very annoying delimiters they put in the file (I think every 1k or 2k, can't remember now).



--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/79ce734e-14d7-42e7-991d-253a95e4bd2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chhil

unread,
Oct 9, 2017, 11:14:57 PM10/9/17
to jpos-...@googlegroups.com

This is what we do (YMMV).
1. Have a xml packager that defines the fields for the messages in a the packager xml file. Note field are defined IFE_*, where E is for EBCDIC.

<isopackager>
  <isofield
      id="0"
      length="4"
      name="MESSAGE TYPE INDICATOR"
      pad="true"
      class="org.jpos.iso.IFE_NUMERIC"/>
  <isofield
      id="1"
      length="16"
      name="BIT MAP"
      class="org.jpos.iso.IFB_BITMAP"/>
  <isofield
      id="2"
      length="19"
      name="PAN - PRIMARY ACCOUNT NUMBER"
      pad="false"
      class="org.jpos.iso.IFE_LLNUM"
  <isofield
      id="3"
      length="6"
      name="PROCESSING CODE"
      pad="true"
      class="org.jpos.iso.IFE_NUMERIC"/>
...
...
2. Read the header bytes.

3. Read the bytes preceeding the MTI and determine the length of the message to read.

4. Read the message bytes.

5. Setup the ISOMsg and assign the packager to it.

6. Use the message bytes and unpack it using the isomsg object.

7. Each field irrespective of the type (EBCDIC etc ) will be available to you as a string.

8. You may have some trailer after messages (@'s, you may need to skip those).

9. You may have some boundary separator chars (@@ at regular intervals, I think we had them at 1021 bytes, skip those, these may come anywhere in between message length, or message data, skip them.

8. Loop to 3 till end of file.

10. I do believe the files come in slightly different formats based on some post processing done on them, so your mileage may vary.

-chhil

Reply all
Reply to author
Forward
0 new messages