mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Added support for "05 Macro" and "06 Macro" in ASCII encodation
git-svn-id: https://zxing.googlecode.com/svn/trunk@526 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
08d44240aa
commit
cebac631ac
|
@ -74,10 +74,11 @@ final class DecodedBitStreamParser {
|
||||||
static String decode(byte[] bytes) throws ReaderException {
|
static String decode(byte[] bytes) throws ReaderException {
|
||||||
BitSource bits = new BitSource(bytes);
|
BitSource bits = new BitSource(bytes);
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
|
StringBuffer resultTrailer = new StringBuffer(0);
|
||||||
int mode = ASCII_ENCODE;
|
int mode = ASCII_ENCODE;
|
||||||
do {
|
do {
|
||||||
if (mode == ASCII_ENCODE) {
|
if (mode == ASCII_ENCODE) {
|
||||||
mode = decodeAsciiSegment(bits, result);
|
mode = decodeAsciiSegment(bits, result, resultTrailer);
|
||||||
} else {
|
} else {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case C40_ENCODE:
|
case C40_ENCODE:
|
||||||
|
@ -101,14 +102,17 @@ final class DecodedBitStreamParser {
|
||||||
mode = ASCII_ENCODE;
|
mode = ASCII_ENCODE;
|
||||||
}
|
}
|
||||||
} while (mode != PAD_ENCODE && bits.available() > 0);
|
} while (mode != PAD_ENCODE && bits.available() > 0);
|
||||||
|
if (resultTrailer.length() > 0) {
|
||||||
|
result.append(resultTrailer);
|
||||||
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See ISO 16022:2006, 5.2.3 and Annex C, Table C.2
|
* See ISO 16022:2006, 5.2.3 and Annex C, Table C.2
|
||||||
*/
|
*/
|
||||||
private static int decodeAsciiSegment(BitSource bits,
|
private static int decodeAsciiSegment(BitSource bits, StringBuffer result, StringBuffer resultTrailer)
|
||||||
StringBuffer result) throws ReaderException {
|
throws ReaderException {
|
||||||
boolean upperShift = false;
|
boolean upperShift = false;
|
||||||
do {
|
do {
|
||||||
int oneByte = bits.readBits(8);
|
int oneByte = bits.readBits(8);
|
||||||
|
@ -140,9 +144,11 @@ final class DecodedBitStreamParser {
|
||||||
} else if (oneByte == 235) { // Upper Shift (shift to Extended ASCII)
|
} else if (oneByte == 235) { // Upper Shift (shift to Extended ASCII)
|
||||||
upperShift = true;
|
upperShift = true;
|
||||||
} else if (oneByte == 236) { // 05 Macro
|
} else if (oneByte == 236) { // 05 Macro
|
||||||
throw new ReaderException("Currently not supporting 05 Macro");
|
result.append("[)>\u001E05\u001D");
|
||||||
} else if (oneByte == 237) { // 06 Macro
|
resultTrailer.insert(0, "\u001E\u0004");
|
||||||
throw new ReaderException("Currently not supporting 06 Macro");
|
} else if (oneByte == 237) { // 06 Macro
|
||||||
|
result.append("[)>\u001E06\u001D");
|
||||||
|
resultTrailer.insert(0, "\u001E\u0004");
|
||||||
} else if (oneByte == 238) { // Latch to ANSI X12 encodation
|
} else if (oneByte == 238) { // Latch to ANSI X12 encodation
|
||||||
return ANSIX12_ENCODE;
|
return ANSIX12_ENCODE;
|
||||||
} else if (oneByte == 239) { // Latch to Text encodation
|
} else if (oneByte == 239) { // Latch to Text encodation
|
||||||
|
|
Loading…
Reference in a new issue