Correct a few more things about ECI parsing
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 19 Jun 2008 16:49:04 +0000 (16:49 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 19 Jun 2008 16:49:04 +0000 (16:49 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@451 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java
core/src/com/google/zxing/qrcode/decoder/Mode.java

index 05339f5..01cabce 100644 (file)
@@ -115,12 +115,10 @@ final class DecodedBitStreamParser {
       return ((firstByte & 0x3F) << 8) | secondByte;
     } else if ((firstByte & 0xE0) == 0xC0) {
       // three bytes
-      int secondByte = bits.readBits(8);
-      int thirdByte = bits.readBits(8);
-      return ((firstByte & 0x1F) << 16) | (secondByte << 8) | thirdByte;
+      int secondThirdBytes = bits.readBits(16);
+      return ((firstByte & 0x1F) << 16) | secondThirdBytes;
     }
-    // FIXME: What should we return here?
-    return 0;
+    throw new IllegalArgumentException("Bad ECI bits starting with byte " + firstByte);
   }
 
   private static void decodeKanjiSegment(BitSource bits,
index 7f1d2f9..d05762f 100644 (file)
@@ -71,8 +71,8 @@ final class Mode {
    *         count of characters that will follow encoded in this {@link Mode}
    */
   int getCharacterCountBits(Version version) {
-    if (this == ECI) {
-      throw new UnsupportedOperationException("Character count doesn't apply to ECI mode");
+    if (this.equals(ECI)) {
+      throw new IllegalArgumentException("Character count doesn't apply to ECI mode");
     }
     int number = version.getVersionNumber();
     int offset;