- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
134 lines
5.0 KiB
Java
134 lines
5.0 KiB
Java
package com.google.zxing.datamatrix.encoder;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class C40Encoder implements Encoder {
|
|
public int getEncodingMode() {
|
|
return 1;
|
|
}
|
|
|
|
@Override // com.google.zxing.datamatrix.encoder.Encoder
|
|
public void encode(EncoderContext encoderContext) {
|
|
StringBuilder sb = new StringBuilder();
|
|
while (true) {
|
|
if (!encoderContext.hasMoreCharacters()) {
|
|
break;
|
|
}
|
|
char currentChar = encoderContext.getCurrentChar();
|
|
encoderContext.pos++;
|
|
int encodeChar = encodeChar(currentChar, sb);
|
|
int codewordCount = encoderContext.getCodewordCount() + ((sb.length() / 3) << 1);
|
|
encoderContext.updateSymbolInfo(codewordCount);
|
|
int dataCapacity = encoderContext.getSymbolInfo().getDataCapacity() - codewordCount;
|
|
if (!encoderContext.hasMoreCharacters()) {
|
|
StringBuilder sb2 = new StringBuilder();
|
|
if (sb.length() % 3 == 2 && (dataCapacity < 2 || dataCapacity > 2)) {
|
|
encodeChar = backtrackOneCharacter(encoderContext, sb, sb2, encodeChar);
|
|
}
|
|
while (sb.length() % 3 == 1 && ((encodeChar <= 3 && dataCapacity != 1) || encodeChar > 3)) {
|
|
encodeChar = backtrackOneCharacter(encoderContext, sb, sb2, encodeChar);
|
|
}
|
|
} else if (sb.length() % 3 == 0 && HighLevelEncoder.lookAheadTest(encoderContext.getMessage(), encoderContext.pos, getEncodingMode()) != getEncodingMode()) {
|
|
encoderContext.signalEncoderChange(0);
|
|
break;
|
|
}
|
|
}
|
|
handleEOD(encoderContext, sb);
|
|
}
|
|
|
|
public final int backtrackOneCharacter(EncoderContext encoderContext, StringBuilder sb, StringBuilder sb2, int i) {
|
|
int length = sb.length();
|
|
sb.delete(length - i, length);
|
|
encoderContext.pos--;
|
|
int encodeChar = encodeChar(encoderContext.getCurrentChar(), sb2);
|
|
encoderContext.resetSymbolInfo();
|
|
return encodeChar;
|
|
}
|
|
|
|
public static void writeNextTriplet(EncoderContext encoderContext, StringBuilder sb) {
|
|
encoderContext.writeCodewords(encodeToCodewords(sb, 0));
|
|
sb.delete(0, 3);
|
|
}
|
|
|
|
public void handleEOD(EncoderContext encoderContext, StringBuilder sb) {
|
|
int length = (sb.length() / 3) << 1;
|
|
int length2 = sb.length() % 3;
|
|
int codewordCount = encoderContext.getCodewordCount() + length;
|
|
encoderContext.updateSymbolInfo(codewordCount);
|
|
int dataCapacity = encoderContext.getSymbolInfo().getDataCapacity() - codewordCount;
|
|
if (length2 == 2) {
|
|
sb.append((char) 0);
|
|
while (sb.length() >= 3) {
|
|
writeNextTriplet(encoderContext, sb);
|
|
}
|
|
if (encoderContext.hasMoreCharacters()) {
|
|
encoderContext.writeCodeword((char) 254);
|
|
}
|
|
} else if (dataCapacity == 1 && length2 == 1) {
|
|
while (sb.length() >= 3) {
|
|
writeNextTriplet(encoderContext, sb);
|
|
}
|
|
if (encoderContext.hasMoreCharacters()) {
|
|
encoderContext.writeCodeword((char) 254);
|
|
}
|
|
encoderContext.pos--;
|
|
} else if (length2 == 0) {
|
|
while (sb.length() >= 3) {
|
|
writeNextTriplet(encoderContext, sb);
|
|
}
|
|
if (dataCapacity > 0 || encoderContext.hasMoreCharacters()) {
|
|
encoderContext.writeCodeword((char) 254);
|
|
}
|
|
} else {
|
|
throw new IllegalStateException("Unexpected case. Please report!");
|
|
}
|
|
encoderContext.signalEncoderChange(0);
|
|
}
|
|
|
|
public int encodeChar(char c, StringBuilder sb) {
|
|
if (c == ' ') {
|
|
sb.append((char) 3);
|
|
return 1;
|
|
}
|
|
if (c >= '0' && c <= '9') {
|
|
sb.append((char) (c - ','));
|
|
return 1;
|
|
}
|
|
if (c >= 'A' && c <= 'Z') {
|
|
sb.append((char) (c - '3'));
|
|
return 1;
|
|
}
|
|
if (c < ' ') {
|
|
sb.append((char) 0);
|
|
sb.append(c);
|
|
return 2;
|
|
}
|
|
if (c >= '!' && c <= '/') {
|
|
sb.append((char) 1);
|
|
sb.append((char) (c - '!'));
|
|
return 2;
|
|
}
|
|
if (c >= ':' && c <= '@') {
|
|
sb.append((char) 1);
|
|
sb.append((char) (c - '+'));
|
|
return 2;
|
|
}
|
|
if (c >= '[' && c <= '_') {
|
|
sb.append((char) 1);
|
|
sb.append((char) (c - 'E'));
|
|
return 2;
|
|
}
|
|
if (c >= '`' && c <= 127) {
|
|
sb.append((char) 2);
|
|
sb.append((char) (c - '`'));
|
|
return 2;
|
|
}
|
|
sb.append("\u0001\u001e");
|
|
return encodeChar((char) (c - 128), sb) + 2;
|
|
}
|
|
|
|
public static String encodeToCodewords(CharSequence charSequence, int i) {
|
|
int charAt = (charSequence.charAt(i) * 1600) + (charSequence.charAt(i + 1) * '(') + charSequence.charAt(i + 2) + 1;
|
|
return new String(new char[]{(char) (charAt / 256), (char) (charAt % 256)});
|
|
}
|
|
}
|