Groups | Blog | Home
all groups > c# > december 2007 >

c# : Parsing Text Files (EDIFACT) and Split() Method


Nicholas Paldino [.NET/C# MVP]
12/14/2007 12:44:38 PM
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#.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

Nicholas Paldino [.NET/C# MVP]
12/14/2007 1:11:51 PM
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.

--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

Robert Fuchs
12/14/2007 6:33:08 PM
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 Fuchs
12/14/2007 6:59:11 PM

[quoted text, click to view]

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
AddThis Social Bookmark Button