@@ -200,6 +200,14 @@ impl Bits {
200
200
( Version :: Micro ( _) , ExtendedMode :: Data ( Mode :: Byte ) ) => 0b10 ,
201
201
( Version :: Micro ( _) , ExtendedMode :: Data ( Mode :: Kanji ) ) => 0b11 ,
202
202
( Version :: Micro ( _) , _) => return Err ( QrError :: UnsupportedCharacterSet ) ,
203
+ ( Version :: RectMicro ( ..) , ExtendedMode :: Data ( Mode :: Numeric ) ) => 0b001 ,
204
+ ( Version :: RectMicro ( ..) , ExtendedMode :: Data ( Mode :: Alphanumeric ) ) => 0b010 ,
205
+ ( Version :: RectMicro ( ..) , ExtendedMode :: Data ( Mode :: Byte ) ) => 0b011 ,
206
+ ( Version :: RectMicro ( ..) , ExtendedMode :: Data ( Mode :: Kanji ) ) => 0b100 ,
207
+ ( Version :: RectMicro ( ..) , ExtendedMode :: Eci ) => 0b111 ,
208
+ ( Version :: RectMicro ( ..) , ExtendedMode :: Fnc1First ) => 0b101 ,
209
+ ( Version :: RectMicro ( ..) , ExtendedMode :: Fnc1Second ) => 0b110 ,
210
+ ( Version :: RectMicro ( ..) , _) => return Err ( QrError :: UnsupportedCharacterSet ) ,
203
211
( _, ExtendedMode :: Data ( Mode :: Numeric ) ) => 0b0001 ,
204
212
( _, ExtendedMode :: Data ( Mode :: Alphanumeric ) ) => 0b0010 ,
205
213
( _, ExtendedMode :: Data ( Mode :: Byte ) ) => 0b0100 ,
@@ -669,8 +677,9 @@ impl Bits {
669
677
//------------------------------------------------------------------------------
670
678
//{{{ Finish
671
679
672
- // This table is copied from ISO/IEC 18004:2006 §6.4.10, Table 7.
673
- static DATA_LENGTHS : [ [ usize ; 4 ] ; 44 ] = [
680
+ // This table is copied from ISO/IEC 18004:2006 §6.4.10, Table 7, and ISO/IEC
681
+ // 23941:2022 Table 6.
682
+ static DATA_LENGTHS : [ [ usize ; 4 ] ; 76 ] = [
674
683
// Normal versions
675
684
[ 152 , 128 , 104 , 72 ] ,
676
685
[ 272 , 224 , 176 , 128 ] ,
@@ -717,6 +726,39 @@ static DATA_LENGTHS: [[usize; 4]; 44] = [
717
726
[ 40 , 32 , 0 , 0 ] ,
718
727
[ 84 , 68 , 0 , 0 ] ,
719
728
[ 128 , 112 , 80 , 0 ] ,
729
+ // rMQR versions
730
+ [ 0 , 48 , 0 , 24 ] ,
731
+ [ 0 , 96 , 0 , 56 ] ,
732
+ [ 0 , 160 , 0 , 80 ] ,
733
+ [ 0 , 224 , 0 , 112 ] ,
734
+ [ 0 , 352 , 0 , 192 ] ,
735
+ [ 0 , 96 , 0 , 56 ] ,
736
+ [ 0 , 168 , 0 , 88 ] ,
737
+ [ 0 , 248 , 0 , 136 ] ,
738
+ [ 0 , 336 , 0 , 176 ] ,
739
+ [ 0 , 504 , 0 , 264 ] ,
740
+ [ 0 , 56 , 0 , 40 ] ,
741
+ [ 0 , 152 , 0 , 88 ] ,
742
+ [ 0 , 248 , 0 , 120 ] ,
743
+ [ 0 , 344 , 0 , 184 ] ,
744
+ [ 0 , 456 , 0 , 232 ] ,
745
+ [ 0 , 672 , 0 , 336 ] ,
746
+ [ 0 , 96 , 0 , 56 ] ,
747
+ [ 0 , 216 , 0 , 104 ] ,
748
+ [ 0 , 304 , 0 , 160 ] ,
749
+ [ 0 , 424 , 0 , 232 ] ,
750
+ [ 0 , 584 , 0 , 280 ] ,
751
+ [ 0 , 848 , 0 , 432 ] ,
752
+ [ 0 , 264 , 0 , 120 ] ,
753
+ [ 0 , 384 , 0 , 208 ] ,
754
+ [ 0 , 536 , 0 , 248 ] ,
755
+ [ 0 , 704 , 0 , 384 ] ,
756
+ [ 0 , 1016 , 0 , 552 ] ,
757
+ [ 0 , 312 , 0 , 168 ] ,
758
+ [ 0 , 448 , 0 , 224 ] ,
759
+ [ 0 , 624 , 0 , 304 ] ,
760
+ [ 0 , 800 , 0 , 448 ] ,
761
+ [ 0 , 1216 , 0 , 608 ] ,
720
762
] ;
721
763
722
764
impl Bits {
@@ -730,7 +772,11 @@ impl Bits {
730
772
/// `ec_level` for the given version (e.g. `Version::Micro(1)` with
731
773
/// `EcLevel::H`).
732
774
pub fn push_terminator ( & mut self , ec_level : EcLevel ) -> QrResult < ( ) > {
733
- let terminator_size = if let Version :: Micro ( a) = self . version { a. as_usize ( ) * 2 + 1 } else { 4 } ;
775
+ let terminator_size = match self . version {
776
+ Version :: Micro ( a) => a. as_usize ( ) * 2 + 1 ,
777
+ Version :: RectMicro ( ..) => 3 ,
778
+ Version :: Normal ( _) => 4 ,
779
+ } ;
734
780
735
781
let cur_length = self . len ( ) ;
736
782
let data_length = self . max_len ( ec_level) ?;
@@ -907,7 +953,7 @@ mod encode_tests {
907
953
/// Automatically determines the minimum version to store the data, and encode
908
954
/// the result.
909
955
///
910
- /// This method will not consider any Micro QR code versions.
956
+ /// This method will not consider any Micro QR code or rMQR code versions.
911
957
///
912
958
/// # Errors
913
959
///
0 commit comments