mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Compacted QR-code: remove needless adding of Mode.TERMINATOR (is taken care of in Encoder.terminateBits) (#1452)
* - added code to suppress the terminator if the capacity of the version is less than 4 bit - added test case * - Removed code in MinimalEncoder that added Mode.TERMINATOR (is taken care of in Encoder.terminateBits) - Removed the corresponding test case * Updated test cases * Improved documentation * Changed documentation to not use an example with an unsupported character encoding * Improved wording of comment * - Simplified code - Added space after comma in several places
This commit is contained in:
parent
128775149b
commit
c729abe393
|
@ -339,6 +339,7 @@ public final class Encoder {
|
|||
throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " > " +
|
||||
capacity);
|
||||
}
|
||||
// Append Mode.TERMINATE if there is enough space (value is 0000)
|
||||
for (int i = 0; i < 4 && bits.getSize() < capacity; ++i) {
|
||||
bits.appendBit(false);
|
||||
}
|
||||
|
|
|
@ -33,46 +33,27 @@ import java.nio.charset.UnsupportedCharsetException;
|
|||
/**
|
||||
* Encoder that encodes minimally
|
||||
*
|
||||
* Version selection:
|
||||
* The version can be preset in the constructor. If it isn't specified then the algorithm will compute three solutions
|
||||
* for the three different version classes 1-9, 10-26 and 27-40.
|
||||
* Algorithm:
|
||||
*
|
||||
* It is not clear to me if ever a solution using for example Medium (Versions 10-26) could be smaller than a Small
|
||||
* solution (Versions 1-9) (proof for or against would be nice to have).
|
||||
* With hypothetical values for the number of length bits, the number of bits per mode and the number of bits per
|
||||
* encoded character it can be shown that it can happen at all as follows:
|
||||
* We hypothetically assume that a mode is encoded using 1 bit (instead of 4) and a character is encoded in BYTE mode
|
||||
* using 2 bit (instead of 8). Using these values we now attempt to encode the four characters "1234".
|
||||
* If we furthermore assume that in Version 1-9 the length field has 1 bit length so that it can encode up to 2
|
||||
* characters and that in Version 10-26 it has 2 bits length so that we can encode up to 2 characters then it is more
|
||||
* efficient to encode with Version 10-26 than with Version 1-9 as shown below:
|
||||
* The eleventh commandment was "Thou Shalt Compute" or "Thou Shalt Not Compute" - I forget which (Alan Perilis).
|
||||
*
|
||||
* Number of length bits small version (1-9): 1
|
||||
* Number of length bits large version (10-26): 2
|
||||
* Number of bits per mode item: 1
|
||||
* Number of bits per character item: 2
|
||||
* BYTE(1,2),BYTE(3,4): 1+1+2+2,1+1+2+2=12 bits
|
||||
* BYTE(1,2,3,4): 1+2+2+2+2+2 =11 bits
|
||||
* This implementation computes. As an alternative, the QR-Code specification suggests heuristics like this one:
|
||||
*
|
||||
* If we however change the capacity of the large encoding from 2 bit to 4 bit so that it potentially can encode 16
|
||||
* items, then it is more efficient to encode using the small encoding
|
||||
* as shown below:
|
||||
* If initial input data is in the exclusive subset of the Alphanumeric character set AND if there are less than
|
||||
* [6,7,8] characters followed by data from the remainder of the 8-bit byte character set, THEN select the 8-
|
||||
* bit byte mode ELSE select Alphanumeric mode;
|
||||
*
|
||||
* Number of length bits small version (1-9): 1
|
||||
* Number of length bits large version (10-26): 4
|
||||
* Number of bits per mode item: 1
|
||||
* Number of bits per character item: 2
|
||||
* BYTE(1,2),BYTE(3,4): 1+1+2+2,1+1+2+2=12 bits
|
||||
* BYTE(1,2,3,4): 1+4+2+2+2+2 =13 bits
|
||||
*
|
||||
* But as mentioned, it is not clear to me if this can ever happen with the actual values.
|
||||
* This is probably right for 99.99% of cases but there is at least this one counter example: The string "AAAAAAa"
|
||||
* encodes 2 bits smaller as ALPHANUMERIC(AAAAAA), BYTE(a) than by encoding it as BYTE(AAAAAAa).
|
||||
* Perhaps that is the only counter example but without having proof, it remains unclear.
|
||||
*
|
||||
* ECI switching:
|
||||
*
|
||||
* In multi language content the algorithm selects the most compact representation using ECI modes. For example the
|
||||
* most compact representation of the string "\u0625\u05D0" is ECI(UTF-8),BYTE(arabic_aleph,hebrew_aleph) while
|
||||
* the encoding the string "\u0625\u0625\u05D0" is most compactly represented with two ECIs as
|
||||
* ECI(ISO-8859-6),BYTE(arabic_aleph,arabic_aleph),ECI(ISO-8859-8),BYTE(hebew_aleph).
|
||||
* In multi language content the algorithm selects the most compact representation using ECI modes.
|
||||
* For example the most compact representation of the string "\u0150\u015C" (O-double-acute, S-circumflex) is
|
||||
* ECI(UTF-8), BYTE(\u0150\u015C) while prepending one or more times the same leading character as in
|
||||
* "\u0150\u0150\u015C", the most compact representation uses two ECIs so that the string is encoded as
|
||||
* ECI(ISO-8859-2), BYTE(\u0150\u0150), ECI(ISO-8859-3), BYTE(\u015C).
|
||||
*
|
||||
* @author Alex Geller
|
||||
*/
|
||||
|
@ -119,7 +100,7 @@ final class MinimalEncoder {
|
|||
this.isGS1 = isGS1;
|
||||
this.ecLevel = ecLevel;
|
||||
|
||||
CharsetEncoder[] isoEncoders = new CharsetEncoder[15]; //room for the 15 ISO-8859 charsets 1 through 16.
|
||||
CharsetEncoder[] isoEncoders = new CharsetEncoder[15]; // room for the 15 ISO-8859 charsets 1 through 16.
|
||||
isoEncoders[0] = StandardCharsets.ISO_8859_1.newEncoder();
|
||||
boolean needUnicodeEncoder = priorityCharset != null && priorityCharset.name().startsWith("UTF");
|
||||
|
||||
|
@ -135,11 +116,11 @@ final class MinimalEncoder {
|
|||
}
|
||||
}
|
||||
|
||||
if (cnt == 14) { //we need all. Can stop looking further.
|
||||
if (cnt == 14) { // we need all. Can stop looking further.
|
||||
break;
|
||||
}
|
||||
|
||||
if (j >= 15) { //no encoder found
|
||||
if (j >= 15) { // no encoder found
|
||||
for (j = 0; j < 15; j++) {
|
||||
if (j != 11 && isoEncoders[j] == null) { // ISO-8859-12 doesn't exist
|
||||
try {
|
||||
|
@ -226,7 +207,7 @@ final class MinimalEncoder {
|
|||
}
|
||||
|
||||
ResultList encode(Version version) throws WriterException {
|
||||
if (version == null) { //compute minimal encoding trying the three version sizes.
|
||||
if (version == null) { // compute minimal encoding trying the three version sizes.
|
||||
final Version[] versions = {getVersion(VersionSize.SMALL),
|
||||
getVersion(VersionSize.MEDIUM),
|
||||
getVersion(VersionSize.LARGE)};
|
||||
|
@ -246,7 +227,7 @@ final class MinimalEncoder {
|
|||
throw new WriterException("Data too big for any version");
|
||||
}
|
||||
return results[smallestResult];
|
||||
} else { //compute minimal encoding for a given version
|
||||
} else { // compute minimal encoding for a given version
|
||||
ResultList result = encodeSpecificVersion(version);
|
||||
if (!Encoder.willFit(result.getSize(), getVersion(getVersionSize(result.getVersion())), ecLevel)) {
|
||||
throw new WriterException("Data too big for version" + version);
|
||||
|
@ -298,8 +279,8 @@ final class MinimalEncoder {
|
|||
case KANJI: return isDoubleByteKanji(c);
|
||||
case ALPHANUMERIC: return isAlphanumeric(c);
|
||||
case NUMERIC: return isNumeric(c);
|
||||
case BYTE: return true; //any character can be encoded as byte(s). Up to the caller to manage splitting into
|
||||
//multiple bytes when String.getBytes(Charset) return more than one byte.
|
||||
case BYTE: return true; // any character can be encoded as byte(s). Up to the caller to manage splitting into
|
||||
// multiple bytes when String.getBytes(Charset) return more than one byte.
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -323,42 +304,6 @@ final class MinimalEncoder {
|
|||
}
|
||||
}
|
||||
|
||||
ResultList postProcess(Edge solution, Version version) {
|
||||
ResultList result = new ResultList(version,solution);
|
||||
Edge edge = solution;
|
||||
if (isGS1) {
|
||||
ResultList.ResultNode first = result.get(0);
|
||||
if (first != null) {
|
||||
if (first.mode != Mode.ECI) {
|
||||
boolean haveECI = false;
|
||||
for (ResultList.ResultNode resultNode : result) {
|
||||
if (resultNode.mode == Mode.ECI) {
|
||||
haveECI = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (haveECI) {
|
||||
//prepend a default character set ECI
|
||||
result.add(0,result.new ResultNode(Mode.ECI, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
first = result.get(0);
|
||||
if (first.mode != Mode.ECI) {
|
||||
//prepend a FNC1_FIRST_POSITION
|
||||
result.add(0,result.new ResultNode(Mode.FNC1_FIRST_POSITION, 0, 0, 0));
|
||||
} else {
|
||||
//insert a FNC1_FIRST_POSITION after the ECI
|
||||
result.add(1,result.new ResultNode(Mode.FNC1_FIRST_POSITION, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
//Add TERMINATOR according to "8.4.8 Terminator"
|
||||
//TODO: The terminator can be omitted if there are less than 4 bit in the capacity of the symbol.
|
||||
result.add(result.new ResultNode(Mode.TERMINATOR, stringToEncode.length(), 0, 0));
|
||||
return result;
|
||||
}
|
||||
|
||||
void addEdge(ArrayList<Edge>[][][] edges, int position, Edge edge) {
|
||||
int vertexIndex = position + edge.characterLength;
|
||||
if (edges[vertexIndex][edge.charsetEncoderIndex][getCompactedOrdinal(edge.mode)] == null) {
|
||||
|
@ -568,7 +513,7 @@ final class MinimalEncoder {
|
|||
if (minimalJ < 0) {
|
||||
throw new WriterException("Internal error: failed to encode \"" + stringToEncode + "\"");
|
||||
}
|
||||
return postProcess(edges[inputLength][minimalJ][minimalK].get(0), version);
|
||||
return new ResultList(version, edges[inputLength][minimalJ][minimalK].get(0));
|
||||
}
|
||||
|
||||
private final class Edge {
|
||||
|
@ -583,7 +528,7 @@ final class MinimalEncoder {
|
|||
this.mode = mode;
|
||||
this.fromPosition = fromPosition;
|
||||
this.charsetEncoderIndex = mode == Mode.BYTE || previous == null ? charsetEncoderIndex :
|
||||
previous.charsetEncoderIndex; //inherit the encoding if not of type BYTE
|
||||
previous.charsetEncoderIndex; // inherit the encoding if not of type BYTE
|
||||
this.characterLength = characterLength;
|
||||
this.previous = previous;
|
||||
|
||||
|
@ -622,10 +567,11 @@ final class MinimalEncoder {
|
|||
|
||||
final Version version;
|
||||
|
||||
ResultList(Version version,Edge solution) {
|
||||
this.version = version;
|
||||
ResultList(Version version, Edge solution) {
|
||||
int length = 0;
|
||||
Edge current = solution;
|
||||
boolean containsECI = false;
|
||||
|
||||
while (current != null) {
|
||||
length += current.characterLength;
|
||||
Edge previous = current.previous;
|
||||
|
@ -634,39 +580,35 @@ final class MinimalEncoder {
|
|||
(previous == null && current.charsetEncoderIndex != 0) || // at the beginning and charset is not ISO-8859-1
|
||||
(previous != null && current.charsetEncoderIndex != previous.charsetEncoderIndex);
|
||||
|
||||
if (needECI) {
|
||||
containsECI = true;
|
||||
}
|
||||
|
||||
if (previous == null || previous.mode != current.mode || needECI) {
|
||||
add(0,new ResultNode(current.mode, current.fromPosition, current.charsetEncoderIndex, length));
|
||||
add(0, new ResultNode(current.mode, current.fromPosition, current.charsetEncoderIndex, length));
|
||||
length = 0;
|
||||
}
|
||||
|
||||
if (needECI) {
|
||||
add(0,new ResultNode(Mode.ECI, current.fromPosition, current.charsetEncoderIndex, 0));
|
||||
add(0, new ResultNode(Mode.ECI, current.fromPosition, current.charsetEncoderIndex, 0));
|
||||
}
|
||||
current = previous;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the size in bits
|
||||
*/
|
||||
int getSize() {
|
||||
int result = 0;
|
||||
for (ResultNode resultNode : this) {
|
||||
result += resultNode.getSize();
|
||||
// prepend FNC1 if needed. If the bits contain an ECI then the FNC1 must be preceeded by an ECI.
|
||||
// If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1)
|
||||
if (isGS1) {
|
||||
ResultNode first = get(0);
|
||||
if (first != null && first.mode != Mode.ECI && containsECI) {
|
||||
// prepend a default character set ECI
|
||||
add(0, new ResultNode(Mode.ECI, 0, 0, 0));
|
||||
}
|
||||
first = get(0);
|
||||
// prepend or insert a FNC1_FIRST_POSITION after the ECI (if any)
|
||||
add(first.mode != Mode.ECI ? 0 : 1, new ResultNode(Mode.FNC1_FIRST_POSITION, 0, 0, 0));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* appends the bits
|
||||
*/
|
||||
void getBits(BitArray bits) throws WriterException {
|
||||
for (ResultNode resultNode : this) {
|
||||
resultNode.getBits(bits);
|
||||
}
|
||||
}
|
||||
|
||||
Version getVersion() {
|
||||
|
||||
// set version to smallest version into which the bits fit.
|
||||
int versionNumber = version.getVersionNumber();
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
@ -685,17 +627,46 @@ final class MinimalEncoder {
|
|||
upperLimit = 40;
|
||||
break;
|
||||
}
|
||||
int size = getSize(version);
|
||||
// increase version if needed
|
||||
while (versionNumber < upperLimit && !Encoder.willFit(getSize(), Version.getVersionForNumber(versionNumber),
|
||||
while (versionNumber < upperLimit && !Encoder.willFit(size, Version.getVersionForNumber(versionNumber),
|
||||
ecLevel)) {
|
||||
versionNumber++;
|
||||
}
|
||||
// shrink version if possible
|
||||
while (versionNumber > lowerLimit && Encoder.willFit(getSize(), Version.getVersionForNumber(versionNumber - 1),
|
||||
while (versionNumber > lowerLimit && Encoder.willFit(size, Version.getVersionForNumber(versionNumber - 1),
|
||||
ecLevel)) {
|
||||
versionNumber--;
|
||||
}
|
||||
return Version.getVersionForNumber(versionNumber);
|
||||
this.version = Version.getVersionForNumber(versionNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the size in bits
|
||||
*/
|
||||
int getSize() {
|
||||
return getSize(version);
|
||||
}
|
||||
|
||||
private int getSize(Version version) {
|
||||
int result = 0;
|
||||
for (ResultNode resultNode : this) {
|
||||
result += resultNode.getSize(version);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* appends the bits
|
||||
*/
|
||||
void getBits(BitArray bits) throws WriterException {
|
||||
for (ResultNode resultNode : this) {
|
||||
resultNode.getBits(bits);
|
||||
}
|
||||
}
|
||||
|
||||
Version getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -728,7 +699,7 @@ final class MinimalEncoder {
|
|||
/**
|
||||
* returns the size in bits
|
||||
*/
|
||||
private int getSize() {
|
||||
private int getSize(Version version) {
|
||||
int size = 4 + mode.getCharacterCountBits(version);
|
||||
switch (mode) {
|
||||
case KANJI:
|
||||
|
|
|
@ -670,218 +670,215 @@ public final class EncoderTestCase extends Assert {
|
|||
|
||||
@Test
|
||||
public void testMinimalEncoder1() throws Exception {
|
||||
verifyMinimalEncoding("A", "ALPHANUMERIC(A),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A", "ALPHANUMERIC(A)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder2() throws Exception {
|
||||
verifyMinimalEncoding("AB", "ALPHANUMERIC(AB),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("AB", "ALPHANUMERIC(AB)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder3() throws Exception {
|
||||
verifyMinimalEncoding("ABC", "ALPHANUMERIC(ABC),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("ABC", "ALPHANUMERIC(ABC)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder4() throws Exception {
|
||||
verifyMinimalEncoding("ABCD", "ALPHANUMERIC(ABCD),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("ABCD", "ALPHANUMERIC(ABCD)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder5() throws Exception {
|
||||
verifyMinimalEncoding("ABCDE", "ALPHANUMERIC(ABCDE),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("ABCDE", "ALPHANUMERIC(ABCDE)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder6() throws Exception {
|
||||
verifyMinimalEncoding("ABCDEF", "ALPHANUMERIC(ABCDEF),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("ABCDEF", "ALPHANUMERIC(ABCDEF)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder7() throws Exception {
|
||||
verifyMinimalEncoding("ABCDEFG", "ALPHANUMERIC(ABCDEFG),TERMINATO" +
|
||||
"R()", null, false);
|
||||
verifyMinimalEncoding("ABCDEFG", "ALPHANUMERIC(ABCDEFG)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder8() throws Exception {
|
||||
verifyMinimalEncoding("1", "NUMERIC(1),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("1", "NUMERIC(1)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder9() throws Exception {
|
||||
verifyMinimalEncoding("12", "NUMERIC(12),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("12", "NUMERIC(12)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder10() throws Exception {
|
||||
verifyMinimalEncoding("123", "NUMERIC(123),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("123", "NUMERIC(123)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder11() throws Exception {
|
||||
verifyMinimalEncoding("1234", "NUMERIC(1234),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("1234", "NUMERIC(1234)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder12() throws Exception {
|
||||
verifyMinimalEncoding("12345", "NUMERIC(12345),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("12345", "NUMERIC(12345)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder13() throws Exception {
|
||||
verifyMinimalEncoding("123456", "NUMERIC(123456),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("123456", "NUMERIC(123456)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder14() throws Exception {
|
||||
verifyMinimalEncoding("123A", "ALPHANUMERIC(123A),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("123A", "ALPHANUMERIC(123A)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder15() throws Exception {
|
||||
verifyMinimalEncoding("A1", "ALPHANUMERIC(A1),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A1", "ALPHANUMERIC(A1)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder16() throws Exception {
|
||||
verifyMinimalEncoding("A12", "ALPHANUMERIC(A12),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A12", "ALPHANUMERIC(A12)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder17() throws Exception {
|
||||
verifyMinimalEncoding("A123", "ALPHANUMERIC(A123),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A123", "ALPHANUMERIC(A123)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder18() throws Exception {
|
||||
verifyMinimalEncoding("A1234", "ALPHANUMERIC(A1234),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A1234", "ALPHANUMERIC(A1234)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder19() throws Exception {
|
||||
verifyMinimalEncoding("A12345", "ALPHANUMERIC(A12345),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A12345", "ALPHANUMERIC(A12345)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder20() throws Exception {
|
||||
verifyMinimalEncoding("A123456", "ALPHANUMERIC(A123456),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A123456", "ALPHANUMERIC(A123456)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder21() throws Exception {
|
||||
verifyMinimalEncoding("A1234567", "ALPHANUMERIC(A1234567),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A1234567", "ALPHANUMERIC(A1234567)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder22() throws Exception {
|
||||
verifyMinimalEncoding("A12345678", "BYTE(A),NUMERIC(12345678),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A12345678", "BYTE(A),NUMERIC(12345678)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder23() throws Exception {
|
||||
verifyMinimalEncoding("A123456789", "BYTE(A),NUMERIC(123456789),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A123456789", "BYTE(A),NUMERIC(123456789)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder24() throws Exception {
|
||||
verifyMinimalEncoding("A1234567890", "ALPHANUMERIC(A1),NUMERIC(234567890),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("A1234567890", "ALPHANUMERIC(A1),NUMERIC(234567890)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder25() throws Exception {
|
||||
verifyMinimalEncoding("AB1", "ALPHANUMERIC(AB1),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("AB1", "ALPHANUMERIC(AB1)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder26() throws Exception {
|
||||
verifyMinimalEncoding("AB12", "ALPHANUMERIC(AB12),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("AB12", "ALPHANUMERIC(AB12)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder27() throws Exception {
|
||||
verifyMinimalEncoding("AB123", "ALPHANUMERIC(AB123),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("AB123", "ALPHANUMERIC(AB123)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder28() throws Exception {
|
||||
verifyMinimalEncoding("AB1234", "ALPHANUMERIC(AB1234),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("AB1234", "ALPHANUMERIC(AB1234)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder29() throws Exception {
|
||||
verifyMinimalEncoding("ABC1", "ALPHANUMERIC(ABC1),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("ABC1", "ALPHANUMERIC(ABC1)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder30() throws Exception {
|
||||
verifyMinimalEncoding("ABC12", "ALPHANUMERIC(ABC12),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("ABC12", "ALPHANUMERIC(ABC12)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder31() throws Exception {
|
||||
verifyMinimalEncoding("ABC1234", "ALPHANUMERIC(ABC1234),TERMINA" +
|
||||
"TOR()", null, false);
|
||||
verifyMinimalEncoding("ABC1234", "ALPHANUMERIC(ABC1234)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder32() throws Exception {
|
||||
verifyMinimalEncoding("http://foo.com", "BYTE(http://foo.com)" +
|
||||
",TERMINATOR()", null, false);
|
||||
"", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder33() throws Exception {
|
||||
verifyMinimalEncoding("HTTP://FOO.COM", "ALPHANUMERIC(HTTP://FOO.COM" +
|
||||
"),TERMINATOR()", null, false);
|
||||
")", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder34() throws Exception {
|
||||
verifyMinimalEncoding("1001114670010%01201220%107211220%140045003267781",
|
||||
"NUMERIC(1001114670010),ALPHANUMERIC(%01201220%107211220%),NUMERIC(140045003267781),TERMINA" +
|
||||
"TOR()", null, false);
|
||||
"NUMERIC(1001114670010),ALPHANUMERIC(%01201220%107211220%),NUMERIC(140045003267781)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder35() throws Exception {
|
||||
verifyMinimalEncoding("\u0150", "ECI(ISO-8859-2),BYTE(.),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("\u0150", "ECI(ISO-8859-2),BYTE(.)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder36() throws Exception {
|
||||
verifyMinimalEncoding("\u015C", "ECI(ISO-8859-3),BYTE(.),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("\u015C", "ECI(ISO-8859-3),BYTE(.)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder37() throws Exception {
|
||||
verifyMinimalEncoding("\u0150\u015C", "ECI(UTF-8),BYTE(..),TERMINATOR()", null, false);
|
||||
verifyMinimalEncoding("\u0150\u015C", "ECI(UTF-8),BYTE(..)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder38() throws Exception {
|
||||
verifyMinimalEncoding("\u0150\u0150\u015C\u015C", "ECI(ISO-8859-2),BYTE(." +
|
||||
".),ECI(ISO-8859-3),BYTE(..),TERMINATOR()", null, false);
|
||||
".),ECI(ISO-8859-3),BYTE(..)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder39() throws Exception {
|
||||
verifyMinimalEncoding("abcdef\u0150ghij", "ECI(ISO-8859-2),BYTE(abcde" +
|
||||
"f.ghij),TERMINATOR()", null, false);
|
||||
"f.ghij)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder40() throws Exception {
|
||||
verifyMinimalEncoding("2938928329832983\u01502938928329832983\u015C2938928329832983",
|
||||
"NUMERIC(2938928329832983),ECI(ISO-8859-2),BYTE(.),NUMERIC(2938928329832983),ECI(ISO-8" +
|
||||
"859-3),BYTE(.),NUMERIC(2938928329832983),TERMINATOR()", null, false);
|
||||
"859-3),BYTE(.),NUMERIC(2938928329832983)", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalEncoder41() throws Exception {
|
||||
verifyMinimalEncoding("1001114670010%01201220%107211220%140045003267781", "FNC1_FIRST_POSITION(),NUMERIC(100111" +
|
||||
"4670010),ALPHANUMERIC(%01201220%107211220%),NUMERIC(140045003267781),TERMINATOR()", null,
|
||||
"4670010),ALPHANUMERIC(%01201220%107211220%),NUMERIC(140045003267781)", null,
|
||||
true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue