File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
app/src/main/java/protect/card_locker Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 2222import java .lang .ref .WeakReference ;
2323import java .nio .charset .Charset ;
2424import java .util .Map ;
25+ import java .util .Objects ;
2526
2627import protect .card_locker .async .CompatCallable ;
2728
@@ -190,7 +191,16 @@ private Bitmap generate() {
190191 } else {
191192 String guessedEncoding = StringUtils .guessEncoding (cardId .getBytes (), new ArrayMap <>());
192193 Log .d (TAG , "Guessed encoding: " + guessedEncoding );
193- encodeHints .put (EncodeHintType .CHARACTER_SET , Charset .forName (guessedEncoding ));
194+
195+ // We don't want to pass the gussed encoding as an encoding hint unless it is UTF-8 as
196+ // zxing is likely to add the mentioned encoding hint as ECI inside the barcode.
197+ //
198+ // Due to many barcode scanners in the wild being badly coded they may trip over ECI
199+ // info existing and fail to scan, such as in https://github.com/CatimaLoyalty/Android/issues/2921
200+ if (Objects .equals (guessedEncoding , "UTF8" )) {
201+ Log .d (TAG , "Guessed encoding is UTF8, so passing as encoding hint" );
202+ encodeHints .put (EncodeHintType .CHARACTER_SET , Charset .forName (guessedEncoding ));
203+ }
194204 }
195205
196206 BitMatrix bitMatrix ;
You can’t perform that action at this time.
0 commit comments