You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently, toEdifact(msg) encodes the last character in msg as "ASCII" even if it is a valid EDIFACT character.
Example
toEdifact('ABCD') => [240, 4, 32, 223, 69]
240: "Start EDIFACT mode" code
[4, 32, 223] after unpacking 3 bytes to 4 EDIFACT codes result in [1, 2, 3, 31] which means 'A', 'B', 'C', 'Return to ASCII mode'.
69: "ASCII" encoding of 'D'
While this works, a more efficient encoding would be [240, 4, 32, 196]:
240: "Start EDIFACT mode" code
[4, 32, 196] unpacked result in [1, 2, 3, 4] which corresponds to 'A', 'B', 'C', 'D'
Code
The culprit is in datamatrix.js/DataMatrix,toEdifact() (note that the if-else systematically skips the last character to place a 31 (="Return to ASCII mode") in front of it):
if (i < l - 1) {
/* encode char */
ch = t.charCodeAt(i);
if (ch < 32 || ch > 94) return []; /* not in set */
} else ch = 31; /* return to ASCII */
The text was updated successfully, but these errors were encountered:
Apparently, toEdifact(msg) encodes the last character in msg as "ASCII" even if it is a valid EDIFACT character.
Example
toEdifact('ABCD') => [240, 4, 32, 223, 69]
While this works, a more efficient encoding would be [240, 4, 32, 196]:
Code
The culprit is in datamatrix.js/DataMatrix,toEdifact() (note that the if-else systematically skips the last character to place a 31 (="Return to ASCII mode") in front of it):
The text was updated successfully, but these errors were encountered: