WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a07d4d1

Browse files
Merge pull request #2940 from CatimaLoyalty/fix/disable_automatic_encoding
Disable automatic barcode encoding guessing for now
2 parents 417006c + 29c4ccf commit a07d4d1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,19 @@ private Bitmap generate() {
190190
if (chosenEncoding != null) {
191191
Log.d(TAG, "Encoding explicitly set, " + chosenEncoding.name());
192192
} else {
193-
chosenEncoding = Charset.forName(StringUtils.guessEncoding(cardId.getBytes(), new ArrayMap<>()));
194-
Log.d(TAG, "Guessed encoding: " + chosenEncoding.name());
193+
// FIXME: Guessing encoding using zxing causes too many false positives and breaks the Deutschlandticket, a common public transport ticket in Germany
194+
// See https://github.com/CatimaLoyalty/Android/issues/2932
195+
//
196+
// So, for now, we just force ISO in the "guessing" path until we figure out a better way to guess
197+
// The previous code is commented before, DO NOT UNCOMMENT, IT IS BROKEN
198+
//
199+
// chosenEncoding = Charset.forName(StringUtils.guessEncoding(cardId.getBytes(), new ArrayMap<>()));
200+
// Log.d(TAG, "Guessed encoding: " + chosenEncoding.name());
201+
202+
// FIXME: Figure out a good way to automatically determine the best format to use, to not break UTF-8 barcodes
203+
// However, make sure to NOT break the Deutschlandticket!
204+
chosenEncoding = StandardCharsets.ISO_8859_1;
205+
Log.w(TAG, "The encoding guessing code path is temporarily disabled due to it breaking Deutschlandticket. Forcing ISO-8859-1...");
195206
}
196207

197208
// We don't want to pass the ISO-8859-1 as an encoding hint as zxing may add this as ECI

0 commit comments

Comments
 (0)