Module | EDI::E |
In: |
lib/edi4r/edifact.rb
lib/edi4r/edifact-rexml.rb |
UN/EDIFACT add-ons to EDI module,
Methods for XML support for the UN/EDIFACT module
Heinz W. Werntges, FH Wiesbaden (edi@informatik.fh-wiesbaden.de)
Copyright © 2006 Heinz W. Werntges. Licensed under the same terms as Ruby.
$Id$
This is the XML add-on for UN/EDIFACT module of edi4r (hence ’::E’)
It leaves all real work to the base classes. Only the UNA information is treated in a special way (as a "Parameter" element of the header) and dealt with here.
Illegal_Charset_Patterns | = | Hash.new(/[^-A-Za-z0-9 .,()\/=!%"&*;<>'+:?\xa0-\xff]+/) | Use pattern for allowed chars of UNOC charset if none given explicitly |
Utility: Separator method for UN/EDIFACT segments/CDEs
The given string typically comprises an EDIFACT segment or a CDE. We want to split it into its elements and return those in an array. The tricky part is the proper handling of character escaping!
Examples:
CDE = "1234:ABC:567" --> ['1234','ABC','567'] CDE = "1234::567" --> ['1234','','567'] CDE = ":::SOMETEXT" --> ['','','','SOMETEXT'] Seg = "TAG+1++2:3:4+A?+B=C" --> ['TAG','1','','2:3:4','A+B=C']
NOTE: This function might be a good candidate for implementation in "C"
Also see: ../../test/test_edi_split.rb
str: | String to split |
s: | Separator char (an Integer) |
e: | Escape / release char (an Integer) |
max: | Max. desired number of result items, default = all |
Returns:
Array of split results (strings without their terminating separator)