@@ -28,16 +28,19 @@ public final class Gs1 {
28
28
29
29
private static final byte DIGITS = 1 ; // 0-9
30
30
private static final byte CHARS_82 = 2 ; // GS1 charset 82
31
- private static final byte CHARS_39 = 3 ; // GS1 charset 39
32
- private static final byte CHARS_UPPERCASE = 4 ; // A-Z
33
- private static final byte FLAG = 5 ; // 0-1
31
+ private static final byte CHARS_64 = 3 ; // GS1 charset 64 (file-safe / URI-safe)
32
+ private static final byte CHARS_39 = 4 ; // GS1 charset 39
33
+ private static final byte CHARS_UPPERCASE = 5 ; // A-Z
34
+ private static final byte FLAG = 6 ; // 0-1
35
+ private static final byte MINUS = 7 ; // minus character ("-")
34
36
35
37
private static final Map < Integer , byte [] > AIS = new HashMap <>();
36
38
37
39
static {
38
40
AIS .put (00 , new byte [] { DIGITS , 18 , 18 }); // N2+N18
39
41
AIS .put (01 , new byte [] { DIGITS , 14 , 14 }); // N2+N14
40
42
AIS .put (02 , new byte [] { DIGITS , 14 , 14 }); // N2+N14
43
+ AIS .put (03 , new byte [] { DIGITS , 14 , 14 }); // N2+N14
41
44
AIS .put (10 , new byte [] { CHARS_82 , 0 , 20 }); // N2+X..20
42
45
AIS .put (11 , new byte [] { DIGITS , 6 , 6 }); // N2+N6
43
46
AIS .put (12 , new byte [] { DIGITS , 6 , 6 }); // N2+N6
@@ -428,10 +431,6 @@ public final class Gs1 {
428
431
AIS .put (3953 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
429
432
AIS .put (3954 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
430
433
AIS .put (3955 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
431
- AIS .put (3956 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
432
- AIS .put (3957 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
433
- AIS .put (3958 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
434
- AIS .put (3959 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
435
434
AIS .put (400 , new byte [] { CHARS_82 , 0 , 30 }); // N3+X..30
436
435
AIS .put (401 , new byte [] { CHARS_82 , 0 , 30 }); // N3+X..30
437
436
AIS .put (402 , new byte [] { DIGITS , 17 , 17 }); // N3+N17
@@ -461,6 +460,7 @@ public final class Gs1 {
461
460
AIS .put (4306 , new byte [] { CHARS_82 , 0 , 70 }); // N4+X..70
462
461
AIS .put (4307 , new byte [] { CHARS_UPPERCASE , 2 , 2 }); // N4+X2
463
462
AIS .put (4308 , new byte [] { CHARS_82 , 0 , 30 }); // N4+X..30
463
+ AIS .put (4309 , new byte [] { DIGITS , 20 , 20 }); // N4+N20
464
464
AIS .put (4310 , new byte [] { CHARS_82 , 0 , 35 }); // N4+X..35
465
465
AIS .put (4311 , new byte [] { CHARS_82 , 0 , 35 }); // N4+X..35
466
466
AIS .put (4312 , new byte [] { CHARS_82 , 0 , 70 }); // N4+X..70
@@ -478,6 +478,10 @@ public final class Gs1 {
478
478
AIS .put (4324 , new byte [] { DIGITS , 10 , 10 }); // N4+N10
479
479
AIS .put (4325 , new byte [] { DIGITS , 10 , 10 }); // N4+N10
480
480
AIS .put (4326 , new byte [] { DIGITS , 6 , 6 }); // N4+N6
481
+ AIS .put (4330 , new byte [] { DIGITS , 6 , 6 , MINUS , 0 , 1 }); // N4+N6+[-]
482
+ AIS .put (4331 , new byte [] { DIGITS , 6 , 6 , MINUS , 0 , 1 }); // N4+N6+[-]
483
+ AIS .put (4332 , new byte [] { DIGITS , 6 , 6 , MINUS , 0 , 1 }); // N4+N6+[-]
484
+ AIS .put (4333 , new byte [] { DIGITS , 6 , 6 , MINUS , 0 , 1 }); // N4+N6+[-]
481
485
AIS .put (7001 , new byte [] { DIGITS , 13 , 13 }); // N4+N13
482
486
AIS .put (7002 , new byte [] { CHARS_82 , 0 , 30 }); // N4+X..30
483
487
AIS .put (7003 , new byte [] { DIGITS , 10 , 10 }); // N4+N10
@@ -488,6 +492,7 @@ public final class Gs1 {
488
492
AIS .put (7008 , new byte [] { CHARS_82 , 0 , 3 }); // N4+X..3
489
493
AIS .put (7009 , new byte [] { CHARS_82 , 0 , 10 }); // N4+X..10
490
494
AIS .put (7010 , new byte [] { CHARS_82 , 0 , 2 }); // N4+X..2
495
+ AIS .put (7011 , new byte [] { DIGITS , 6 , 10 }); // N4+N6..10
491
496
AIS .put (7020 , new byte [] { CHARS_82 , 0 , 20 }); // N4+X..20
492
497
AIS .put (7021 , new byte [] { CHARS_82 , 0 , 20 }); // N4+X..20
493
498
AIS .put (7022 , new byte [] { CHARS_82 , 0 , 20 }); // N4+X..20
@@ -503,12 +508,14 @@ public final class Gs1 {
503
508
AIS .put (7038 , new byte [] { DIGITS , 3 , 3 , CHARS_82 , 0 , 27 }); // N4+N3+X..27
504
509
AIS .put (7039 , new byte [] { DIGITS , 3 , 3 , CHARS_82 , 0 , 27 }); // N4+N3+X..27
505
510
AIS .put (7040 , new byte [] { DIGITS , 1 , 1 , CHARS_82 , 3 , 3 }); // N4+N1+X3
511
+ AIS .put (7041 , new byte [] { CHARS_82 , 0 , 4 }); // N4+X..4
506
512
AIS .put (710 , new byte [] { CHARS_82 , 0 , 20 }); // N3+X..20
507
513
AIS .put (711 , new byte [] { CHARS_82 , 0 , 20 }); // N3+X..20
508
514
AIS .put (712 , new byte [] { CHARS_82 , 0 , 20 }); // N3+X..20
509
515
AIS .put (713 , new byte [] { CHARS_82 , 0 , 20 }); // N3+X..20
510
516
AIS .put (714 , new byte [] { CHARS_82 , 0 , 20 }); // N3+X..20
511
517
AIS .put (715 , new byte [] { CHARS_82 , 0 , 20 }); // N3+X..20
518
+ AIS .put (716 , new byte [] { CHARS_82 , 0 , 20 }); // N3+X..20
512
519
AIS .put (7230 , new byte [] { CHARS_82 , 2 , 30 }); // N4+X2+X..28
513
520
AIS .put (7231 , new byte [] { CHARS_82 , 2 , 30 }); // N4+X2+X..28
514
521
AIS .put (7232 , new byte [] { CHARS_82 , 2 , 30 }); // N4+X2+X..28
@@ -520,6 +527,18 @@ public final class Gs1 {
520
527
AIS .put (7238 , new byte [] { CHARS_82 , 2 , 30 }); // N4+X2+X..28
521
528
AIS .put (7239 , new byte [] { CHARS_82 , 2 , 30 }); // N4+X2+X..28
522
529
AIS .put (7240 , new byte [] { CHARS_82 , 0 , 20 }); // N4+X..20
530
+ AIS .put (7241 , new byte [] { DIGITS , 2 , 2 }); // N4+N2
531
+ AIS .put (7242 , new byte [] { CHARS_82 , 0 , 25 }); // N4+X..25
532
+ AIS .put (7250 , new byte [] { DIGITS , 8 , 8 }); // N4+N8
533
+ AIS .put (7251 , new byte [] { DIGITS , 12 , 12 }); // N4+N12
534
+ AIS .put (7252 , new byte [] { DIGITS , 1 , 1 }); // N4+N1
535
+ AIS .put (7253 , new byte [] { CHARS_82 , 0 , 40 }); // N4+X..40
536
+ AIS .put (7254 , new byte [] { CHARS_82 , 0 , 40 }); // N4+X..40
537
+ AIS .put (7255 , new byte [] { CHARS_82 , 0 , 10 }); // N4+X..10
538
+ AIS .put (7256 , new byte [] { CHARS_82 , 0 , 90 }); // N4+X..90
539
+ AIS .put (7257 , new byte [] { CHARS_82 , 0 , 70 }); // N4+X..70
540
+ AIS .put (7258 , new byte [] { DIGITS , 1 , 1 , CHARS_82 , 1 , 1 , DIGITS , 1 , 1 }); // N4+N1+X1+N1
541
+ AIS .put (7259 , new byte [] { CHARS_82 , 0 , 40 }); // N4+X..40
523
542
AIS .put (8001 , new byte [] { DIGITS , 14 , 14 }); // N4+N14
524
543
AIS .put (8002 , new byte [] { CHARS_82 , 0 , 20 }); // N4+X..20
525
544
AIS .put (8003 , new byte [] { DIGITS , 14 , 14 , CHARS_82 , 0 , 16 }); // N4+N14+X..16
@@ -533,11 +552,13 @@ public final class Gs1 {
533
552
AIS .put (8011 , new byte [] { DIGITS , 0 , 12 }); // N4+N..12
534
553
AIS .put (8012 , new byte [] { CHARS_82 , 0 , 20 }); // N4+X..20
535
554
AIS .put (8013 , new byte [] { CHARS_82 , 0 , 25 }); // N4+X..25
555
+ AIS .put (8014 , new byte [] { CHARS_82 , 0 , 25 }); // N4+X..25
536
556
AIS .put (8017 , new byte [] { DIGITS , 18 , 18 }); // N4+N18
537
557
AIS .put (8018 , new byte [] { DIGITS , 18 , 18 }); // N4+N18
538
558
AIS .put (8019 , new byte [] { DIGITS , 0 , 10 }); // N4+N..10
539
559
AIS .put (8020 , new byte [] { CHARS_82 , 0 , 25 }); // N4+X..25
540
560
AIS .put (8026 , new byte [] { DIGITS , 18 , 18 }); // N4+N14+N2+N2
561
+ AIS .put (8030 , new byte [] { CHARS_64 , 0 , 90 }); // N4+Z..90
541
562
AIS .put (8110 , new byte [] { CHARS_82 , 0 , 70 }); // N4+X..70
542
563
AIS .put (8111 , new byte [] { DIGITS , 4 , 4 }); // N4+N4
543
564
AIS .put (8112 , new byte [] { CHARS_82 , 0 , 70 }); // N4+X..70
@@ -568,7 +589,7 @@ private Gs1() {
568
589
* @param fnc1 the string to use to represent FNC1 in the output
569
590
* @return the input data, verified and with FNC1 strings added at the appropriate positions
570
591
* @see <a href="https://sourceforge.net/p/zint/code/ci/master/tree/backend/gs1.c">Corresponding Zint code</a>
571
- * @see <a href="http ://www .gs1.org/docs/gsmp/barcodes/GS1_General_Specifications.pdf ">GS1 specification</a>
592
+ * @see <a href="https ://ref .gs1.org/standards/genspecs/ ">GS1 specification</a>
572
593
*/
573
594
public static String verify (String s , String fnc1 ) {
574
595
@@ -714,9 +735,11 @@ public static String verify(String s, String fnc1) {
714
735
boolean valid =
715
736
(type == DIGITS && c >= '0' && c <= '9' ) ||
716
737
(type == CHARS_82 && ((c >= 'A' && c <= 'Z' ) || (c >= 'a' && c <= 'z' ) || (c >= '%' && c <= '?' ) || c == '_' || c == '!' || c == '"' )) ||
738
+ (type == CHARS_64 && ((c >= 'A' && c <= 'Z' ) || (c >= 'a' && c <= 'z' ) || (c >= '0' && c <= '9' ) || c == '_' || c == '-' || c == '=' )) ||
717
739
(type == CHARS_39 && ((c >= 'A' && c <= 'Z' ) || (c >= '0' && c <= '9' ) || c == '#' || c == '-' || c == '/' )) ||
718
740
(type == FLAG && c >= '0' && c <= '1' ) ||
719
- (type == CHARS_UPPERCASE && c >= 'A' && c <= 'Z' );
741
+ (type == CHARS_UPPERCASE && c >= 'A' && c <= 'Z' ) ||
742
+ (type == MINUS && c == '-' );
720
743
if (!valid ) {
721
744
throw new OkapiInputException ("Invalid data value for AI " + ai );
722
745
}
0 commit comments