"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/main/java/com/google/zxing/oned/Code39Writer.java" between
zxing-zxing-3.4.1.tar.gz and zxing-zxing-3.5.0.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. Info: Project is in maintenance mode (no active development).

Code39Writer.java  (zxing-zxing-3.4.1):Code39Writer.java  (zxing-zxing-3.5.0)
skipping to change at line 51 skipping to change at line 51
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + le ngth); "Requested contents should be less than 80 digits long, but got " + le ngth);
} }
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i )); int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i ));
if (indexInString < 0) { if (indexInString < 0) {
contents = tryToConvertToExtendedMode(contents); contents = tryToConvertToExtendedMode(contents);
length = contents.length(); length = contents.length();
if (length > 80) { if (length > 80) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Requested contents should be less
"Requested contents should be less than 80 digits long, but got " than 80 digits long, but got " +
+ length + " (extended full ASCII mode)"); length + " (extended full ASCII mode)");
} }
break; break;
} }
} }
int[] widths = new int[9]; int[] widths = new int[9];
int codeWidth = 24 + 1 + (13 * length); int codeWidth = 24 + 1 + (13 * length);
boolean[] result = new boolean[codeWidth]; boolean[] result = new boolean[codeWidth];
toIntArray(Code39Reader.ASTERISK_ENCODING, widths); toIntArray(Code39Reader.ASTERISK_ENCODING, widths);
int pos = appendPattern(result, 0, widths, true); int pos = appendPattern(result, 0, widths, true);
skipping to change at line 85 skipping to change at line 85
} }
private static void toIntArray(int a, int[] toReturn) { private static void toIntArray(int a, int[] toReturn) {
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
int temp = a & (1 << (8 - i)); int temp = a & (1 << (8 - i));
toReturn[i] = temp == 0 ? 1 : 2; toReturn[i] = temp == 0 ? 1 : 2;
} }
} }
private static String tryToConvertToExtendedMode(String contents) { private static String tryToConvertToExtendedMode(String contents) {
int length = contents.length(); int length = contents.length();
StringBuilder extendedContent = new StringBuilder(); StringBuilder extendedContent = new StringBuilder();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
char character = contents.charAt(i); char character = contents.charAt(i);
switch (character) { switch (character) {
case '\u0000': case '\u0000':
extendedContent.append("%U"); extendedContent.append("%U");
break; break;
case ' ': case ' ':
case '-': case '-':
case '.': case '.':
extendedContent.append(character); extendedContent.append(character);
break; break;
case '@': case '@':
extendedContent.append("%V"); extendedContent.append("%V");
break; break;
case '`': case '`':
extendedContent.append("%W"); extendedContent.append("%W");
break; break;
default: default:
if (character <= 26) { if (character <= 26) {
extendedContent.append('$'); extendedContent.append('$');
extendedContent.append((char) ('A' + (character - 1))); extendedContent.append((char) ('A' + (character - 1)));
} else if (character < ' ') { } else if (character < ' ') {
extendedContent.append('%'); extendedContent.append('%');
extendedContent.append((char) ('A' + (character - 27))); extendedContent.append((char) ('A' + (character - 27)));
} else if (character <= ',' || character == '/' || character == ':') } else if (character <= ',' || character == '/' || character == ':') {
{ extendedContent.append('/');
extendedContent.append('/'); extendedContent.append((char) ('A' + (character - 33)));
extendedContent.append((char) ('A' + (character - 33))); } else if (character <= '9') {
} else if (character <= '9') { extendedContent.append((char) ('0' + (character - 48)));
extendedContent.append((char) ('0' + (character - 48))); } else if (character <= '?') {
} else if (character <= '?') { extendedContent.append('%');
extendedContent.append('%'); extendedContent.append((char) ('F' + (character - 59)));
extendedContent.append((char) ('F' + (character - 59))); } else if (character <= 'Z') {
} else if (character <= 'Z') { extendedContent.append((char) ('A' + (character - 65)));
extendedContent.append((char) ('A' + (character - 65))); } else if (character <= '_') {
} else if (character <= '_') { extendedContent.append('%');
extendedContent.append('%'); extendedContent.append((char) ('K' + (character - 91)));
extendedContent.append((char) ('K' + (character - 91))); } else if (character <= 'z') {
} else if (character <= 'z') { extendedContent.append('+');
extendedContent.append('+'); extendedContent.append((char) ('A' + (character - 97)));
extendedContent.append((char) ('A' + (character - 97))); } else if (character <= 127) {
} else if (character <= 127) { extendedContent.append('%');
extendedContent.append('%'); extendedContent.append((char) ('P' + (character - 123)));
extendedContent.append((char) ('P' + (character - 123))); } else {
} else { throw new IllegalArgumentException(
throw new IllegalArgumentException( "Requested content contains a non-encodable character: '" + cont
"Requested content contains a non-encodable character: '" + conte ents.charAt(i) + "'");
nts.charAt(i) + "'"); }
} break;
break; }
}
} }
return extendedContent.toString(); return extendedContent.toString();
} }
} }
 End of changes. 2 change blocks. 
56 lines changed or deleted 55 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)