Parsing Text Files (EDIFACT) and Split() Method

  • Thread starter Thread starter Robert Fuchs
  • Start date Start date
R

Robert Fuchs

Hi,

an EDIFACT segment starts with a 3 letter acronym and ends with an
apostrophe.
Segments consist of composites, delimited by a plus sign, and composites
consist of data elements, delimited by semicolon, eg.:

BGM+220:::Order+0040750+9'


There is an additional rule, when a delimiter will need to be interpreted as
a normal character and not a delimiter. This can be detected by a question
mark preceding the delimiter, eg.:

FTX+AAI+++ROCK?'N?'ROLL'

The question mark itself is repesented as ??.

Now my problem is, that the Split() method doesn't recognize this.
Is there any other fancy class/method in the framework I could use, or do I
have to go the hard way by reading each character into a state machine -
like I did in C for decades?

regards, Robert
 
Robert,

There definitely isn't any method in the framework that will do this.
You ^might^ be able to craft a regular expression for this, but it could be
pretty unwieldy (especially if you are not familiar with them).

If you already have the code for a state machine in C++, you should be
able to leverage that, or in the worst case scenario, convert it to C#.
 
There definitely isn't any method in the framework that will do this.
You ^might^ be able to craft a regular expression for this, but it could
be pretty unwieldy (especially if you are not familiar with them).

If you already have the code for a state machine in C++, you should be
able to leverage that, or in the worst case scenario, convert it to C#.

I was concerned about that.
I have done a lot of C programming for more than 20 years, but not so much
C++, unfortunately.
When I switched to C#, I found myself writing a lot of stuff which was
already in the framework.
I googled for EDIFACT and was surprised that there is so little information
available.

Thanks, Robert
 
Robert,

Well, EDIFACT isn't what would be considered "general purpose" which is
probably why it is not included in the general framework (I think that
BizTalk does process EDI documents though, unless you are referring to
something else).

C or C++, it doesn't really matter. If you are comfortable with C, then
that's fine. You can easily take your C code and compile it into a DLL (if
it isn't already) and then call the appropriate functions in .NET/C# through
the P/Invoke layer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top