mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
561 lines
22 KiB
Java
561 lines
22 KiB
Java
|
package com.google.zxing.qrcode.encoder;
|
||
|
|
||
|
import com.google.zxing.WriterException;
|
||
|
import com.google.zxing.common.BitArray;
|
||
|
import com.google.zxing.common.CharacterSetECI;
|
||
|
import com.google.zxing.common.reedsolomon.GenericGF;
|
||
|
import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;
|
||
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||
|
import com.google.zxing.qrcode.decoder.Mode;
|
||
|
import com.google.zxing.qrcode.decoder.Version;
|
||
|
import java.io.UnsupportedEncodingException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Iterator;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public final class Encoder {
|
||
|
private static final int[] ALPHANUMERIC_TABLE = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1};
|
||
|
static final String DEFAULT_BYTE_MODE_ENCODING = "ISO-8859-1";
|
||
|
|
||
|
private Encoder() {
|
||
|
}
|
||
|
|
||
|
private static int calculateMaskPenalty(ByteMatrix byteMatrix) {
|
||
|
return MaskUtil.applyMaskPenaltyRule1(byteMatrix) + MaskUtil.applyMaskPenaltyRule2(byteMatrix) + MaskUtil.applyMaskPenaltyRule3(byteMatrix) + MaskUtil.applyMaskPenaltyRule4(byteMatrix);
|
||
|
}
|
||
|
|
||
|
public static QRCode encode(String str, ErrorCorrectionLevel errorCorrectionLevel) throws WriterException {
|
||
|
return encode(str, errorCorrectionLevel, null);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:36:0x00fc, code lost:
|
||
|
|
||
|
if (com.google.zxing.qrcode.encoder.QRCode.isValidMaskPattern(r7) != false) goto L44;
|
||
|
*/
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public static com.google.zxing.qrcode.encoder.QRCode encode(java.lang.String r5, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel r6, java.util.Map<com.google.zxing.EncodeHintType, ?> r7) throws com.google.zxing.WriterException {
|
||
|
/*
|
||
|
if (r7 == 0) goto Lc
|
||
|
com.google.zxing.EncodeHintType r0 = com.google.zxing.EncodeHintType.CHARACTER_SET
|
||
|
boolean r0 = r7.containsKey(r0)
|
||
|
if (r0 == 0) goto Lc
|
||
|
r0 = 1
|
||
|
goto Ld
|
||
|
Lc:
|
||
|
r0 = 0
|
||
|
Ld:
|
||
|
if (r0 == 0) goto L1a
|
||
|
com.google.zxing.EncodeHintType r1 = com.google.zxing.EncodeHintType.CHARACTER_SET
|
||
|
java.lang.Object r1 = r7.get(r1)
|
||
|
java.lang.String r1 = r1.toString()
|
||
|
goto L1c
|
||
|
L1a:
|
||
|
java.lang.String r1 = "ISO-8859-1"
|
||
|
L1c:
|
||
|
com.google.zxing.qrcode.decoder.Mode r2 = chooseMode(r5, r1)
|
||
|
com.google.zxing.common.BitArray r3 = new com.google.zxing.common.BitArray
|
||
|
r3.<init>()
|
||
|
com.google.zxing.qrcode.decoder.Mode r4 = com.google.zxing.qrcode.decoder.Mode.BYTE
|
||
|
if (r2 != r4) goto L34
|
||
|
if (r0 == 0) goto L34
|
||
|
com.google.zxing.common.CharacterSetECI r0 = com.google.zxing.common.CharacterSetECI.getCharacterSetECIByName(r1)
|
||
|
if (r0 == 0) goto L34
|
||
|
appendECI(r0, r3)
|
||
|
L34:
|
||
|
if (r7 == 0) goto L53
|
||
|
com.google.zxing.EncodeHintType r0 = com.google.zxing.EncodeHintType.GS1_FORMAT
|
||
|
boolean r0 = r7.containsKey(r0)
|
||
|
if (r0 == 0) goto L53
|
||
|
com.google.zxing.EncodeHintType r0 = com.google.zxing.EncodeHintType.GS1_FORMAT
|
||
|
java.lang.Object r0 = r7.get(r0)
|
||
|
java.lang.String r0 = r0.toString()
|
||
|
boolean r0 = java.lang.Boolean.parseBoolean(r0)
|
||
|
if (r0 == 0) goto L53
|
||
|
com.google.zxing.qrcode.decoder.Mode r0 = com.google.zxing.qrcode.decoder.Mode.FNC1_FIRST_POSITION
|
||
|
appendModeInfo(r0, r3)
|
||
|
L53:
|
||
|
appendModeInfo(r2, r3)
|
||
|
com.google.zxing.common.BitArray r0 = new com.google.zxing.common.BitArray
|
||
|
r0.<init>()
|
||
|
appendBytes(r5, r2, r0, r1)
|
||
|
if (r7 == 0) goto L8d
|
||
|
com.google.zxing.EncodeHintType r1 = com.google.zxing.EncodeHintType.QR_VERSION
|
||
|
boolean r1 = r7.containsKey(r1)
|
||
|
if (r1 == 0) goto L8d
|
||
|
com.google.zxing.EncodeHintType r1 = com.google.zxing.EncodeHintType.QR_VERSION
|
||
|
java.lang.Object r1 = r7.get(r1)
|
||
|
java.lang.String r1 = r1.toString()
|
||
|
int r1 = java.lang.Integer.parseInt(r1)
|
||
|
com.google.zxing.qrcode.decoder.Version r1 = com.google.zxing.qrcode.decoder.Version.getVersionForNumber(r1)
|
||
|
int r4 = calculateBitsNeeded(r2, r3, r0, r1)
|
||
|
boolean r4 = willFit(r4, r1, r6)
|
||
|
if (r4 == 0) goto L85
|
||
|
goto L91
|
||
|
L85:
|
||
|
com.google.zxing.WriterException r5 = new com.google.zxing.WriterException
|
||
|
java.lang.String r6 = "Data too big for requested version"
|
||
|
r5.<init>(r6)
|
||
|
throw r5
|
||
|
L8d:
|
||
|
com.google.zxing.qrcode.decoder.Version r1 = recommendVersion(r6, r2, r3, r0)
|
||
|
L91:
|
||
|
com.google.zxing.common.BitArray r4 = new com.google.zxing.common.BitArray
|
||
|
r4.<init>()
|
||
|
r4.appendBitArray(r3)
|
||
|
com.google.zxing.qrcode.decoder.Mode r3 = com.google.zxing.qrcode.decoder.Mode.BYTE
|
||
|
if (r2 != r3) goto La2
|
||
|
int r5 = r0.getSizeInBytes()
|
||
|
goto La6
|
||
|
La2:
|
||
|
int r5 = r5.length()
|
||
|
La6:
|
||
|
appendLengthInfo(r5, r1, r2, r4)
|
||
|
r4.appendBitArray(r0)
|
||
|
com.google.zxing.qrcode.decoder.Version$ECBlocks r5 = r1.getECBlocksForLevel(r6)
|
||
|
int r0 = r1.getTotalCodewords()
|
||
|
int r3 = r5.getTotalECCodewords()
|
||
|
int r0 = r0 - r3
|
||
|
terminateBits(r0, r4)
|
||
|
int r3 = r1.getTotalCodewords()
|
||
|
int r5 = r5.getNumBlocks()
|
||
|
com.google.zxing.common.BitArray r5 = interleaveWithECBytes(r4, r3, r0, r5)
|
||
|
com.google.zxing.qrcode.encoder.QRCode r0 = new com.google.zxing.qrcode.encoder.QRCode
|
||
|
r0.<init>()
|
||
|
r0.setECLevel(r6)
|
||
|
r0.setMode(r2)
|
||
|
r0.setVersion(r1)
|
||
|
int r2 = r1.getDimensionForVersion()
|
||
|
com.google.zxing.qrcode.encoder.ByteMatrix r3 = new com.google.zxing.qrcode.encoder.ByteMatrix
|
||
|
r3.<init>(r2, r2)
|
||
|
r2 = -1
|
||
|
if (r7 == 0) goto Lff
|
||
|
com.google.zxing.EncodeHintType r4 = com.google.zxing.EncodeHintType.QR_MASK_PATTERN
|
||
|
boolean r4 = r7.containsKey(r4)
|
||
|
if (r4 == 0) goto Lff
|
||
|
com.google.zxing.EncodeHintType r4 = com.google.zxing.EncodeHintType.QR_MASK_PATTERN
|
||
|
java.lang.Object r7 = r7.get(r4)
|
||
|
java.lang.String r7 = r7.toString()
|
||
|
int r7 = java.lang.Integer.parseInt(r7)
|
||
|
boolean r4 = com.google.zxing.qrcode.encoder.QRCode.isValidMaskPattern(r7)
|
||
|
if (r4 == 0) goto Lff
|
||
|
goto L100
|
||
|
Lff:
|
||
|
r7 = r2
|
||
|
L100:
|
||
|
if (r7 != r2) goto L106
|
||
|
int r7 = chooseMaskPattern(r5, r6, r1, r3)
|
||
|
L106:
|
||
|
r0.setMaskPattern(r7)
|
||
|
com.google.zxing.qrcode.encoder.MatrixUtil.buildMatrix(r5, r6, r1, r7, r3)
|
||
|
r0.setMatrix(r3)
|
||
|
return r0
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.encoder.Encoder.encode(java.lang.String, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel, java.util.Map):com.google.zxing.qrcode.encoder.QRCode");
|
||
|
}
|
||
|
|
||
|
private static Version recommendVersion(ErrorCorrectionLevel errorCorrectionLevel, Mode mode, BitArray bitArray, BitArray bitArray2) throws WriterException {
|
||
|
return chooseVersion(calculateBitsNeeded(mode, bitArray, bitArray2, chooseVersion(calculateBitsNeeded(mode, bitArray, bitArray2, Version.getVersionForNumber(1)), errorCorrectionLevel)), errorCorrectionLevel);
|
||
|
}
|
||
|
|
||
|
private static int calculateBitsNeeded(Mode mode, BitArray bitArray, BitArray bitArray2, Version version) {
|
||
|
return bitArray.getSize() + mode.getCharacterCountBits(version) + bitArray2.getSize();
|
||
|
}
|
||
|
|
||
|
static int getAlphanumericCode(int i) {
|
||
|
int[] iArr = ALPHANUMERIC_TABLE;
|
||
|
if (i < iArr.length) {
|
||
|
return iArr[i];
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
public static Mode chooseMode(String str) {
|
||
|
return chooseMode(str, null);
|
||
|
}
|
||
|
|
||
|
private static Mode chooseMode(String str, String str2) {
|
||
|
if ("Shift_JIS".equals(str2) && isOnlyDoubleByteKanji(str)) {
|
||
|
return Mode.KANJI;
|
||
|
}
|
||
|
boolean z = false;
|
||
|
boolean z2 = false;
|
||
|
for (int i = 0; i < str.length(); i++) {
|
||
|
char charAt = str.charAt(i);
|
||
|
if (charAt >= '0' && charAt <= '9') {
|
||
|
z2 = true;
|
||
|
} else {
|
||
|
if (getAlphanumericCode(charAt) == -1) {
|
||
|
return Mode.BYTE;
|
||
|
}
|
||
|
z = true;
|
||
|
}
|
||
|
}
|
||
|
if (z) {
|
||
|
return Mode.ALPHANUMERIC;
|
||
|
}
|
||
|
if (z2) {
|
||
|
return Mode.NUMERIC;
|
||
|
}
|
||
|
return Mode.BYTE;
|
||
|
}
|
||
|
|
||
|
private static boolean isOnlyDoubleByteKanji(String str) {
|
||
|
try {
|
||
|
byte[] bytes = str.getBytes("Shift_JIS");
|
||
|
int length = bytes.length;
|
||
|
if (length % 2 != 0) {
|
||
|
return false;
|
||
|
}
|
||
|
for (int i = 0; i < length; i += 2) {
|
||
|
int i2 = bytes[i] & 255;
|
||
|
if ((i2 < 129 || i2 > 159) && (i2 < 224 || i2 > 235)) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
} catch (UnsupportedEncodingException unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static int chooseMaskPattern(BitArray bitArray, ErrorCorrectionLevel errorCorrectionLevel, Version version, ByteMatrix byteMatrix) throws WriterException {
|
||
|
int i = Integer.MAX_VALUE;
|
||
|
int i2 = -1;
|
||
|
for (int i3 = 0; i3 < 8; i3++) {
|
||
|
MatrixUtil.buildMatrix(bitArray, errorCorrectionLevel, version, i3, byteMatrix);
|
||
|
int calculateMaskPenalty = calculateMaskPenalty(byteMatrix);
|
||
|
if (calculateMaskPenalty < i) {
|
||
|
i2 = i3;
|
||
|
i = calculateMaskPenalty;
|
||
|
}
|
||
|
}
|
||
|
return i2;
|
||
|
}
|
||
|
|
||
|
private static Version chooseVersion(int i, ErrorCorrectionLevel errorCorrectionLevel) throws WriterException {
|
||
|
for (int i2 = 1; i2 <= 40; i2++) {
|
||
|
Version versionForNumber = Version.getVersionForNumber(i2);
|
||
|
if (willFit(i, versionForNumber, errorCorrectionLevel)) {
|
||
|
return versionForNumber;
|
||
|
}
|
||
|
}
|
||
|
throw new WriterException("Data too big");
|
||
|
}
|
||
|
|
||
|
private static boolean willFit(int i, Version version, ErrorCorrectionLevel errorCorrectionLevel) {
|
||
|
return version.getTotalCodewords() - version.getECBlocksForLevel(errorCorrectionLevel).getTotalECCodewords() >= (i + 7) / 8;
|
||
|
}
|
||
|
|
||
|
static void terminateBits(int i, BitArray bitArray) throws WriterException {
|
||
|
int i2 = i << 3;
|
||
|
if (bitArray.getSize() > i2) {
|
||
|
throw new WriterException("data bits cannot fit in the QR Code" + bitArray.getSize() + " > " + i2);
|
||
|
}
|
||
|
for (int i3 = 0; i3 < 4 && bitArray.getSize() < i2; i3++) {
|
||
|
bitArray.appendBit(false);
|
||
|
}
|
||
|
int size = bitArray.getSize() & 7;
|
||
|
if (size > 0) {
|
||
|
while (size < 8) {
|
||
|
bitArray.appendBit(false);
|
||
|
size++;
|
||
|
}
|
||
|
}
|
||
|
int sizeInBytes = i - bitArray.getSizeInBytes();
|
||
|
for (int i4 = 0; i4 < sizeInBytes; i4++) {
|
||
|
bitArray.appendBits((i4 & 1) == 0 ? 236 : 17, 8);
|
||
|
}
|
||
|
if (bitArray.getSize() != i2) {
|
||
|
throw new WriterException("Bits size does not equal capacity");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void getNumDataBytesAndNumECBytesForBlockID(int i, int i2, int i3, int i4, int[] iArr, int[] iArr2) throws WriterException {
|
||
|
if (i4 >= i3) {
|
||
|
throw new WriterException("Block ID too large");
|
||
|
}
|
||
|
int i5 = i % i3;
|
||
|
int i6 = i3 - i5;
|
||
|
int i7 = i / i3;
|
||
|
int i8 = i7 + 1;
|
||
|
int i9 = i2 / i3;
|
||
|
int i10 = i9 + 1;
|
||
|
int i11 = i7 - i9;
|
||
|
int i12 = i8 - i10;
|
||
|
if (i11 != i12) {
|
||
|
throw new WriterException("EC bytes mismatch");
|
||
|
}
|
||
|
if (i3 != i6 + i5) {
|
||
|
throw new WriterException("RS blocks mismatch");
|
||
|
}
|
||
|
if (i != ((i9 + i11) * i6) + ((i10 + i12) * i5)) {
|
||
|
throw new WriterException("Total bytes mismatch");
|
||
|
}
|
||
|
if (i4 < i6) {
|
||
|
iArr[0] = i9;
|
||
|
iArr2[0] = i11;
|
||
|
} else {
|
||
|
iArr[0] = i10;
|
||
|
iArr2[0] = i12;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static BitArray interleaveWithECBytes(BitArray bitArray, int i, int i2, int i3) throws WriterException {
|
||
|
if (bitArray.getSizeInBytes() != i2) {
|
||
|
throw new WriterException("Number of bits and data bytes does not match");
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(i3);
|
||
|
int i4 = 0;
|
||
|
int i5 = 0;
|
||
|
int i6 = 0;
|
||
|
for (int i7 = 0; i7 < i3; i7++) {
|
||
|
int[] iArr = new int[1];
|
||
|
int[] iArr2 = new int[1];
|
||
|
getNumDataBytesAndNumECBytesForBlockID(i, i2, i3, i7, iArr, iArr2);
|
||
|
int i8 = iArr[0];
|
||
|
byte[] bArr = new byte[i8];
|
||
|
bitArray.toBytes(i4 << 3, bArr, 0, i8);
|
||
|
byte[] generateECBytes = generateECBytes(bArr, iArr2[0]);
|
||
|
arrayList.add(new BlockPair(bArr, generateECBytes));
|
||
|
i5 = Math.max(i5, i8);
|
||
|
i6 = Math.max(i6, generateECBytes.length);
|
||
|
i4 += iArr[0];
|
||
|
}
|
||
|
if (i2 != i4) {
|
||
|
throw new WriterException("Data bytes does not match offset");
|
||
|
}
|
||
|
BitArray bitArray2 = new BitArray();
|
||
|
for (int i9 = 0; i9 < i5; i9++) {
|
||
|
Iterator it = arrayList.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
byte[] dataBytes = ((BlockPair) it.next()).getDataBytes();
|
||
|
if (i9 < dataBytes.length) {
|
||
|
bitArray2.appendBits(dataBytes[i9], 8);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
for (int i10 = 0; i10 < i6; i10++) {
|
||
|
Iterator it2 = arrayList.iterator();
|
||
|
while (it2.hasNext()) {
|
||
|
byte[] errorCorrectionBytes = ((BlockPair) it2.next()).getErrorCorrectionBytes();
|
||
|
if (i10 < errorCorrectionBytes.length) {
|
||
|
bitArray2.appendBits(errorCorrectionBytes[i10], 8);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (i == bitArray2.getSizeInBytes()) {
|
||
|
return bitArray2;
|
||
|
}
|
||
|
throw new WriterException("Interleaving error: " + i + " and " + bitArray2.getSizeInBytes() + " differ.");
|
||
|
}
|
||
|
|
||
|
static byte[] generateECBytes(byte[] bArr, int i) {
|
||
|
int length = bArr.length;
|
||
|
int[] iArr = new int[length + i];
|
||
|
for (int i2 = 0; i2 < length; i2++) {
|
||
|
iArr[i2] = bArr[i2] & 255;
|
||
|
}
|
||
|
new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(iArr, i);
|
||
|
byte[] bArr2 = new byte[i];
|
||
|
for (int i3 = 0; i3 < i; i3++) {
|
||
|
bArr2[i3] = (byte) iArr[length + i3];
|
||
|
}
|
||
|
return bArr2;
|
||
|
}
|
||
|
|
||
|
static void appendModeInfo(Mode mode, BitArray bitArray) {
|
||
|
bitArray.appendBits(mode.getBits(), 4);
|
||
|
}
|
||
|
|
||
|
static void appendLengthInfo(int i, Version version, Mode mode, BitArray bitArray) throws WriterException {
|
||
|
int characterCountBits = mode.getCharacterCountBits(version);
|
||
|
int i2 = 1 << characterCountBits;
|
||
|
if (i >= i2) {
|
||
|
throw new WriterException(i + " is bigger than " + (i2 - 1));
|
||
|
}
|
||
|
bitArray.appendBits(i, characterCountBits);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: com.google.zxing.qrcode.encoder.Encoder$1, reason: invalid class name */
|
||
|
/* loaded from: classes3.dex */
|
||
|
public static /* synthetic */ class AnonymousClass1 {
|
||
|
static final /* synthetic */ int[] $SwitchMap$com$google$zxing$qrcode$decoder$Mode;
|
||
|
|
||
|
static {
|
||
|
int[] iArr = new int[Mode.values().length];
|
||
|
$SwitchMap$com$google$zxing$qrcode$decoder$Mode = iArr;
|
||
|
try {
|
||
|
iArr[Mode.NUMERIC.ordinal()] = 1;
|
||
|
} catch (NoSuchFieldError unused) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$google$zxing$qrcode$decoder$Mode[Mode.ALPHANUMERIC.ordinal()] = 2;
|
||
|
} catch (NoSuchFieldError unused2) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$google$zxing$qrcode$decoder$Mode[Mode.BYTE.ordinal()] = 3;
|
||
|
} catch (NoSuchFieldError unused3) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$google$zxing$qrcode$decoder$Mode[Mode.KANJI.ordinal()] = 4;
|
||
|
} catch (NoSuchFieldError unused4) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void appendBytes(String str, Mode mode, BitArray bitArray, String str2) throws WriterException {
|
||
|
int i = AnonymousClass1.$SwitchMap$com$google$zxing$qrcode$decoder$Mode[mode.ordinal()];
|
||
|
if (i == 1) {
|
||
|
appendNumericBytes(str, bitArray);
|
||
|
return;
|
||
|
}
|
||
|
if (i == 2) {
|
||
|
appendAlphanumericBytes(str, bitArray);
|
||
|
} else if (i == 3) {
|
||
|
append8BitBytes(str, bitArray, str2);
|
||
|
} else {
|
||
|
if (i == 4) {
|
||
|
appendKanjiBytes(str, bitArray);
|
||
|
return;
|
||
|
}
|
||
|
throw new WriterException("Invalid mode: ".concat(String.valueOf(mode)));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void appendNumericBytes(CharSequence charSequence, BitArray bitArray) {
|
||
|
int length = charSequence.length();
|
||
|
int i = 0;
|
||
|
while (i < length) {
|
||
|
int charAt = charSequence.charAt(i) - '0';
|
||
|
int i2 = i + 2;
|
||
|
if (i2 < length) {
|
||
|
bitArray.appendBits((charAt * 100) + ((charSequence.charAt(i + 1) - '0') * 10) + (charSequence.charAt(i2) - '0'), 10);
|
||
|
i += 3;
|
||
|
} else {
|
||
|
i++;
|
||
|
if (i < length) {
|
||
|
bitArray.appendBits((charAt * 10) + (charSequence.charAt(i) - '0'), 7);
|
||
|
i = i2;
|
||
|
} else {
|
||
|
bitArray.appendBits(charAt, 4);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void appendAlphanumericBytes(CharSequence charSequence, BitArray bitArray) throws WriterException {
|
||
|
int length = charSequence.length();
|
||
|
int i = 0;
|
||
|
while (i < length) {
|
||
|
int alphanumericCode = getAlphanumericCode(charSequence.charAt(i));
|
||
|
if (alphanumericCode == -1) {
|
||
|
throw new WriterException();
|
||
|
}
|
||
|
int i2 = i + 1;
|
||
|
if (i2 < length) {
|
||
|
int alphanumericCode2 = getAlphanumericCode(charSequence.charAt(i2));
|
||
|
if (alphanumericCode2 == -1) {
|
||
|
throw new WriterException();
|
||
|
}
|
||
|
bitArray.appendBits((alphanumericCode * 45) + alphanumericCode2, 11);
|
||
|
i += 2;
|
||
|
} else {
|
||
|
bitArray.appendBits(alphanumericCode, 6);
|
||
|
i = i2;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void append8BitBytes(String str, BitArray bitArray, String str2) throws WriterException {
|
||
|
try {
|
||
|
for (byte b : str.getBytes(str2)) {
|
||
|
bitArray.appendBits(b, 8);
|
||
|
}
|
||
|
} catch (UnsupportedEncodingException e) {
|
||
|
throw new WriterException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:13:0x003c A[LOOP:0: B:6:0x000f->B:13:0x003c, LOOP_END] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:14:0x004b A[SYNTHETIC] */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
static void appendKanjiBytes(java.lang.String r6, com.google.zxing.common.BitArray r7) throws com.google.zxing.WriterException {
|
||
|
/*
|
||
|
java.lang.String r0 = "Shift_JIS"
|
||
|
byte[] r6 = r6.getBytes(r0) // Catch: java.io.UnsupportedEncodingException -> L5c
|
||
|
int r0 = r6.length
|
||
|
int r0 = r0 % 2
|
||
|
if (r0 != 0) goto L54
|
||
|
int r0 = r6.length
|
||
|
int r0 = r0 + (-1)
|
||
|
r1 = 0
|
||
|
Lf:
|
||
|
if (r1 >= r0) goto L53
|
||
|
r2 = r6[r1]
|
||
|
r2 = r2 & 255(0xff, float:3.57E-43)
|
||
|
int r3 = r1 + 1
|
||
|
r3 = r6[r3]
|
||
|
r3 = r3 & 255(0xff, float:3.57E-43)
|
||
|
int r2 = r2 << 8
|
||
|
r2 = r2 | r3
|
||
|
r3 = 33088(0x8140, float:4.6366E-41)
|
||
|
r4 = -1
|
||
|
if (r2 < r3) goto L2b
|
||
|
r5 = 40956(0x9ffc, float:5.7392E-41)
|
||
|
if (r2 > r5) goto L2b
|
||
|
L29:
|
||
|
int r2 = r2 - r3
|
||
|
goto L3a
|
||
|
L2b:
|
||
|
r3 = 57408(0xe040, float:8.0446E-41)
|
||
|
if (r2 < r3) goto L39
|
||
|
r3 = 60351(0xebbf, float:8.457E-41)
|
||
|
if (r2 > r3) goto L39
|
||
|
r3 = 49472(0xc140, float:6.9325E-41)
|
||
|
goto L29
|
||
|
L39:
|
||
|
r2 = r4
|
||
|
L3a:
|
||
|
if (r2 == r4) goto L4b
|
||
|
int r3 = r2 >> 8
|
||
|
int r3 = r3 * 192
|
||
|
r2 = r2 & 255(0xff, float:3.57E-43)
|
||
|
int r3 = r3 + r2
|
||
|
r2 = 13
|
||
|
r7.appendBits(r3, r2)
|
||
|
int r1 = r1 + 2
|
||
|
goto Lf
|
||
|
L4b:
|
||
|
com.google.zxing.WriterException r6 = new com.google.zxing.WriterException
|
||
|
java.lang.String r7 = "Invalid byte sequence"
|
||
|
r6.<init>(r7)
|
||
|
throw r6
|
||
|
L53:
|
||
|
return
|
||
|
L54:
|
||
|
com.google.zxing.WriterException r6 = new com.google.zxing.WriterException
|
||
|
java.lang.String r7 = "Kanji byte size not even"
|
||
|
r6.<init>(r7)
|
||
|
throw r6
|
||
|
L5c:
|
||
|
r6 = move-exception
|
||
|
com.google.zxing.WriterException r7 = new com.google.zxing.WriterException
|
||
|
r7.<init>(r6)
|
||
|
throw r7
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.encoder.Encoder.appendKanjiBytes(java.lang.String, com.google.zxing.common.BitArray):void");
|
||
|
}
|
||
|
|
||
|
private static void appendECI(CharacterSetECI characterSetECI, BitArray bitArray) {
|
||
|
bitArray.appendBits(Mode.ECI.getBits(), 4);
|
||
|
bitArray.appendBits(characterSetECI.getValue(), 8);
|
||
|
}
|
||
|
}
|