diff --git a/src/core/aztec/decoder/Decoder.ts b/src/core/aztec/decoder/Decoder.ts index 7d891cae..a8c229d3 100644 --- a/src/core/aztec/decoder/Decoder.ts +++ b/src/core/aztec/decoder/Decoder.ts @@ -56,11 +56,9 @@ export default class Decoder { ]; private static MIXED_TABLE: string[] = [ - // Module parse failed: Octal literal in strict mode (50:29) - // so number string were scaped - 'CTRL_PS', ' ', '\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '\\7', '\b', '\t', '\n', - '\\13', '\f', '\r', '\\33', '\\34', '\\35', '\\36', '\\37', '@', '\\', '^', '_', - '`', '|', '~', '\\177', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS' + 'CTRL_PS', ' ', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\b', '\t', '\n', + '\x0b', '\f', '\r', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', '@', '\\', '^', '_', + '`', '|', '~', '\x7f', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS' ]; private static PUNCT_TABLE: string[] = [ diff --git a/src/test/core/aztec/decoder/Decoder.spec.ts b/src/test/core/aztec/decoder/Decoder.spec.ts index 415d8ce7..fad128b4 100644 --- a/src/test/core/aztec/decoder/Decoder.spec.ts +++ b/src/test/core/aztec/decoder/Decoder.spec.ts @@ -155,6 +155,38 @@ describe('DecoderTest', () => { assertThrow(() => new AztecDecoder().decode(r), FormatException); }); + /** + * @Test + */ + it('testDecodeSpecialCharacters', () => { + const matrix = BitMatrix.parseFromString( + 'X X . . . X X . X X . X . . . . . . X \n' + + 'X . . X X . X . . X . . . X . X X X . \n' + + 'X . X . X X X X . . . X . . . . X . X \n' + + '. . . X X . X . . . . X . X X . X . X \n' + + 'X . X . X X . X . . X X . . X . . . . \n' + + '. . . X X X X X X X X X X X X X . X X \n' + + '. X X X . X . . . . . . . X . X X . X \n' + + 'X . X . X X . X X X X X . X X . . . . \n' + + '. X . X X X . X . . . X . X X . . X . \n' + + '. . . . . X . X . X . X . X . . . . X \n' + + '. . . X . X . X . . . X . X . . X X . \n' + + 'X . . . . X . X X X X X . X . X X X . \n' + + 'X . X . . X . . . . . . . X . X X . . \n' + + '. X X . . X X X X X X X X X X X . . . \n' + + 'X . X . . . X X X X X . . . . X . X X \n' + + '. . . X X X . . . X X X . X X . X X X \n' + + 'X X X . X X X X . X . X X . X X X X . \n' + + '. . . X . . X X . . X . X . X X . X X \n' + + 'X X . . X . X X X . . . . X . . . X X \n', + 'X ', '. '); + const r = new AztecDetectorResult(matrix, NO_POINTS, true, 14, 2); + const result = new AztecDecoder().decode(r); + assertEquals( + '\x01\x02\x03\x04\x05\x06\x07\x0b\x1b\x1c\x1d\x1e\x1f\x7f', + result.getText()); + }); + /** * @Test */