3

I am implementing an EDI-x12 header parser (only to parse "ISA" segment) I notice that there are several character sets can be used.

My question is that how do I know that which one is used of incoming edi-x12 message so that I know how to interpret the message?

Machavity
  • 30,841
  • 27
  • 92
  • 100
kai
  • 1,141
  • 3
  • 15
  • 25

2 Answers2

5

actually there is no such thing as a character set in x12. this is up to the partners/interchange agreement. but as X12 is mainly used in USA, it is us-ascii (almost always). (but .....some companies send x12 as EBCEDIC ;-)))

eppye
  • 710
  • 4
  • 9
  • if the document is encoded in EBCDIC, is the whole document encoded in EBCDIC or part of them in ASCII and part of them in EBCDIC allowed since I saw some document is mostly encoded in ASCII while it also includes non-printable characters... – kai Nov 22 '11 at 02:11
  • 1
    if EBCDIC, all is EBCDIC. I did not believe this, but I really saw this. The 'standard' is really vague about this. – eppye Nov 22 '11 at 10:43
  • 1
    The standard gives a list of chars that must be supported. The encoding can be customized between partners. Charset != encoding. If you stick with the set of chars specified by ANSI X12, then converting between EBCDIC/ASCII is a simple mapping. – Stuart Gathman Oct 16 '18 at 15:50
  • 1
    so, you re-phrase the question: how do you know the encoding? than answer that question... – eppye Oct 17 '18 at 17:42
4

If you're only doing ANSI X12, the ISA segment should be easy for you to parse, as it is a fixed length.

Position 4 will give you the element delimiter (field delimiter).
Position 106 will give you the record terminator.
Position 105 will give you the subelement delimiter

You probably won't have much use for the subelement delimiter, depending on the document type. Once you figure out what your field delimiters are and then the record delimiter, it should be a snap.

(Standard disclaimer: there are many great tools out there in the form of data translators that make this job much simpler than having a programmer reinvent the wheel. Some of these tools are even open source and free. Just sayin'...)

Hope this helps.

Andrew
  • 2,801
  • 1
  • 26
  • 27