package com.google.zxing.qrcode.decoder;
import com.google.zxing.ReaderException;
+import com.google.zxing.common.BitSource;
import java.io.UnsupportedEncodingException;
/**
* See ISO 18004:2006, 6.4.4 Table 5
*/
- private static final char[] ALPHANUMERIC_CHARS = new char[]{
+ private static final char[] ALPHANUMERIC_CHARS = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
' ', '$', '%', '*', '+', '-', '.', '/', ':'
};
private static final String SHIFT_JIS = "Shift_JIS";
+ private static final String EUC_JP = "EUC-JP";
private static final boolean ASSUME_SHIFT_JIS;
private static final String UTF8 = "UTF-8";
private static final String ISO88591 = "ISO-8859-1";
static {
String platformDefault = System.getProperty("file.encoding");
- ASSUME_SHIFT_JIS = SHIFT_JIS.equalsIgnoreCase(platformDefault) ||
- "EUC-JP".equalsIgnoreCase(platformDefault);
+ ASSUME_SHIFT_JIS = SHIFT_JIS.equalsIgnoreCase(platformDefault) || EUC_JP.equalsIgnoreCase(platformDefault);
}
private DecodedBitStreamParser() {
Mode mode;
do {
// While still another segment to read...
- mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits
+ if (bits.available() == 0) {
+ // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here
+ mode = Mode.TERMINATOR;
+ } else {
+ mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits
+ }
if (!mode.equals(Mode.TERMINATOR)) {
// How many characters will follow, encoded in this mode?
int count = bits.readBits(mode.getCharacterCountBits(version));