Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#607 Wrong characters for Aztec decoder in Decoder.MIXED_TABLE #608

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/core/aztec/decoder/Decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
32 changes: 32 additions & 0 deletions src/test/core/aztec/decoder/Decoder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down