Framework EDI Reference. Encoding Mechanism
EDA Filter

The EDA filter converts characters in a document to the UN/EDIFACT Syntax Level A character set.  This character set contains 56 characters, but the following are excluded for use in the encoding:

In addition, the space is not used as a character to map.  This leaves 43 characters.

The following table is the Syntax Level A character set.  The characters colored are those excluded in the encoding.

Character Description Notes
1 . Full Stop
2 , Comma
3 - Hyphen
4 ( Open Parenthesis
5 ) Close Parenthesis
6 / Oblique Stroke
7 = Equal
8 SP Space
9 ! Exclamation Mark Telex Transmission
10 " Quotation Mark Telex Transmission
11 % Percent Telex Transmission
12 & Ampersand Telex Transmission
13 * Asterisk Telex Transmission
14 ; Semi Colon Telex Transmission
15 < Less Than Sign Telex Transmission
16 > Greater Than Sign Telex Transmission
17 : Colon Used for Sub Element Separator
18 ' Apostrophe Used for Segment Terminator
19 + Plus Used for Element Terminator
20 ? Question Mark Used for Release Indicator
21 - 30 0 1 2 3 4 5 6 7 8 9 All Numbers
31 - 56 A B C D E F G H I J K L M N O PQ R S T U V W X Y Z All Upper Case Alphabets

 

Encoding

The procedure for encoding is as follows:

  1. The data is subdivided into 2 byte pairs.  For documents having an uneven count of bytes, the last byte will not be paired.
  2. For each pair, 3 numbers are generated from its decimal value to represent the pair.  This is done as follows:
    1. The first number is the result of dividing the 2 byte decimal value by 1849 (43^2).
    2. The second number is the result of dividing the remainder (modulo) of step 1 by 43.
    3. The third number is the result of the remainder (modulo) of step 2.

      Example.  The 3 number representation for the two byte value 0xAD 0xFF is 24, 3, and 38.  The decimal value of 0xADxFF is 44543, and the calculation is as follows: 
      1. 44543 divide by 1849 is 24.
      2. 44543 modulo 1849 is 167;  167 divide by 43 is 3.
      3. 167 modulo 43 is 38.
  3. If there is an unmatched single byte at the end of the document then 2 numbers are generated:
    1. The first number is the result of dividing the one byte decimal value by 43.
    2. The second number is the result of the remainder of step 1.

      Example.  The 2 number number representation for the one byte value 0xBC is 4 and 16.  The decimal value of 0xBC is 188, and the calculation is as follows:
      1. 188 divide by 43 is 4.
      2. 188 modulo 43 is 16.
  4. The generated 3 or 2 numbers are then mapped to the following table to generate their corresponding 3 or 2 encoded characters:

    Map Table.

    Number Encoded Char
    00 0
    01 1
    02 2
    03 3
    04 4
    05 5
    06 6
    07 7
    08 8
    09 9
    10 A
    11 B
    12 C
    13 D
    14 E
    15 F
    16 G
    17 H
    18 I
    19 J
    20 K
    21 L
    Number Encoded Char
    22 M
    23 N
    24 O
    25 P
    26 Q
    27 R
    28 S
    29 T
    30 U
    31 V
    32 W
    33 X
    34 Y
    35 Z
    36 (
    37 )
    38 ,
    39 -
    40 .
    41 /
    42 =

    Example.  The 3 character representation for the two byte value 0xAD 0xFF is "O3,".  The decimal value of 0xADxFF is 44543, and the calculation is as follows: 
    1. 44543 divide by 1849 is 24.  The number 24 maps to "O".
    2. 44543 modulo 1849 is 167;  167 divide by 43 is 3.  The number 3 maps to "3".
    3. 167 modulo 43 is 38.  The number 38 maps to "," (comma).

Decoding

The procedure for decoding is as follows:

  1. For each encoded character in the document, using the map table convert the character to its corresponding number ranging from 0 to 42.  Note that a properly encoded document will only contain characters shown on the right side of the map.
  2. Subdivide the stream of numbers in 3 sets, and for each set, generate a 2-byte decimal value using the following formula: 

    (N1 * 1849) + (N2 * 43) + N3

    1. Multiply the first number in the set with 1849 (43^2).
    2. Multiply the second number in the set with 43.
    3. Add the third number with the products calculated in step 1 and 2.
  3. If the last bytes only make up a set of 2, then generate a 1-byte decimal  value using the formula:

    (N1 * 43) + N2

    1. Multiply the first number in the set with 43.
    2. Add the second number with the product calculated in step 1.

Example

For example to encode the string "The 5 men of 223rd St" using EDA filter, the byte stream would be as follows:

Text

T h e 5 m e n o f 2 2 3 r d S t

Original Byte Stream

0x54 0x68 0x65 0x20 0x35 0x20 0x6D 0x65 0x6E 0x20 0x6F 0x66 0x20 0x32 0x32 0x33 0x72 0x64 0x20 0x53 0x74
3-Num Representation 11 29 22 14 00 02 07 15 12 15 06 12 15 10 27 15 18 09 04 19 29 06 40 37 15 36 01 04 20 19 02 30

EDA Characters

B T M E 0 2 7 F C F 6 C F A R F I 9 4 J T 6 . ) F ( 1 4 K J 2 U

EDA Byte Stream

x42 x54 x4D x45 x30 x32 x37 x46 x43 x46 x36 x43 x46 x41 x52 x46 x49 x39 x34 x4A x54 x36 x2E x29 x46 x28 x31 x34 x4B x4A x32 x55