# Rectangular Micro QR Code

Rectangular Micro QR Code (also known as rMQR Code) is two-dimensional (2D) matrix barcode invented and standardized in 2022 by Denso Wave as ISO/IEC 23941. rMQR Code is designed as a rectangular variation of QR code and has the same parameters and applications as original QR code. But rMQR Code is more suitable for the rectangular areas and has difference between width and height up to 19 in R7x139 version. In this way it can be used in places where 1D barcodes are used. rMQR Code can replace Code 128 and Code 39 barcodes with more effective data encoding.
rMQR Code consists of black squares and white square spaces arranged in a square grid on a white background. It has one finder pattern in left-top corner the same as in QR Code and small finder sub-pattern in right-bottom corner. Also, it has alignment and timing patterns to help with recognition. rMQR Code has Reed–Solomon error correction with ability to restore data from corrupted barcodes. As other 2D matrix barcodes it can be read with camera-based readers.
As original QR code, rMQR Code can encode Unicode characters with Extended Channel Interpretation feature, bytes array and can natively encode Japanese characters in kanji encoding. In maximal R17x139 version rMQR Code can encode up to 361 numeric, 219 alphanumeric, 150 bytes and 92 kanji characters.

## History and application

rMQR Code was invented by Denso Wave company in 2022 and standardized as ISO/IEC 23941. It is an extension of QR Code for rectangular areas and designed to be a replacement of 1D barcodes.
rMQR Code is a novel barcode and at this time it not widely used, but it can unite QR Code features like error correction and Unicode encoding and 1D barcodes features like effective usage of rectangular areas. At this time rMQR Code yet is not widely supported by hardware printers and scanners but it is already supported by barcode libraries. In this way rMQR Code can be used in:
* Advertisement;
* Automatic data identification in document processing;
* Automatically identified hyperlinks to internet pages;
* Food and goods tracking in retail;
* In airports, bus / railroad stations for automatic tickets and passenger documents identification;
* Package tracking;
* Patient or medicine identification in healthcare services or industry.
Main advantages of rMQR Code are:
* Ability to encode Japanese characters with embedded methods;
* Effective usage of rectangular areas and full replacement of 1D barcodes.
* Encoding GS1 Data;
* Extended Channel Interpretation support;
* Reed–Solomon error correction with ability to restore data from corrupted barcodes.

## Barcode design

Rectangular Micro QR Code is designed for the better utilization of rectangular areas with all features of QR code. The symbology consists of black squares and white square spaces arranged in a square grid on a white background. Additionally, the barcode has inverse version with black background with inverse (luminance) color of elements.$^{:6.2}$
rMQR Code has minimal height of 7X and minimal width of 27X, where maximal height is 17X and maximal width 139X.$^{:7.1}$ rMQR Code has 32 versions with different combinations of height and width. Reed–Solomon error correction has two levels and allows to restore from 15% to 30% of corrupted data.
rMQR Code symbol is constructed from the following elements:$^{:6.3.1}$
* Finder pattern on top-left corner with 1X separator on bottom-right space, the same as in QR Code;
* Finder sub pattern in bottom-right corner;
* Corner finder patterns on top-right and bottom-left barcode sides, width and height variable and maximal can be 3x3;
* Alignment patterns, variable count, depends from version width: 0 in R11x27 version, 8 in R11x139 version;
* Timing patterns which are used as border around barcode;
* Format information region around finder pattern and finder sub pattern;
* Data encoding region;
* Quiet zone 2X.
Here are some samples of Rectangular Micro QR Code (rMQR Code):
* Rectangular Micro QR Code (rMQR Code) version R7x43
* Rectangular Micro QR Code (rMQR Code) version R17x43
* Rectangular Micro QR Code (rMQR Code) version R7x139
* Rectangular Micro QR Code (rMQR Code) version R17x139
* Rectangular Micro QR Code (rMQR Code) version R11x77
* Rectangular Micro QR Code (rMQR Code) version R15x59

### Versions

Rectangular Micro QR Code can be encoded in 32 versions with height from 7X to 17X and width from 27X to 139X. All versions have two Error correction levels: M and H, which have influence on possible encoded data size and error correction. All of Rectangular Micro QR Code versions and their features can be watched in the following table:$^{:7.4.10}$
Rectangular Micro QR Code (rMQR Code) Versions :
| Version | Version indicator | Error correction level | Data codewords | Error correction codewords | Data capacity | Data capacity | Data capacity | Data capacity |
| Version | Version indicator | Error correction level | Data codewords | Error correction codewords | Numeric | Alpha | Byte | Kanji |
| R7x43 | 0 | M | 6 | 7 | 12 | 7 | 5 | 3 |
| R7x43 | 0 | H | 3 | 10 | 5 | 3 | 2 | 1 |
| R7x59 | 1 | M | 12 | 9 | 26 | 16 | 11 | 6 |
| R7x59 | 1 | H | 7 | 14 | 14 | 8 | 6 | 3 |
| R7x77 | 2 | M | 20 | 12 | 45 | 27 | 19 | 11 |
| R7x77 | 2 | H | 10 | 22 | 21 | 13 | 9 | 5 |
| R7x99 | 3 | M | 28 | 16 | 64 | 39 | 27 | 16 |
| R7x99 | 3 | H | 14 | 30 | 30 | 18 | 13 | 8 |
| R7x139 | 4 | M | 44 | 24 | 102 | 62 | 42 | 26 |
| R7x139 | 4 | H | 24 | 44 | 54 | 33 | 22 | 14 |
| R9x43 | 5 | M | 12 | 9 | 26 | 16 | 11 | 6 |
| R9x43 | 5 | H | 7 | 14 | 14 | 8 | 6 | 3 |
| R9x59 | 6 | M | 21 | 12 | 47 | 29 | 20 | 12 |
| R9x59 | 6 | H | 11 | 22 | 23 | 14 | 10 | 6 |
| R9x77 | 7 | M | 31 | 18 | 71 | 43 | 30 | 18 |
| R9x77 | 7 | H | 17 | 32 | 37 | 23 | 16 | 9 |
| R9x99 | 8 | M | 42 | 24 | 97 | 59 | 40 | 25 |
| R9x99 | 8 | H | 22 | 44 | 49 | 30 | 20 | 12 |
| R9x139 | 9 | M | 63 | 36 | 147 | 89 | 61 | 38 |
| R9x139 | 9 | H | 33 | 66 | 75 | 46 | 31 | 19 |
| R11x27 | 10 | M | 7 | 8 | 14 | 8 | 6 | 3 |
| R11x27 | 10 | H | 5 | 10 | 9 | 6 | 4 | 2 |
| R11x43 | 11 | M | 19 | 12 | 42 | 26 | 18 | 11 |
| R11x43 | 11 | H | 11 | 20 | 23 | 14 | 10 | 6 |
| R11x59 | 12 | M | 31 | 16 | 71 | 43 | 30 | 18 |
| R11x59 | 12 | H | 15 | 32 | 33 | 20 | 14 | 8 |
| R11x77 | 13 | M | 43 | 24 | 33 | 20 | 14 | 8 |
| R11x77 | 13 | H | 23 | 44 | 52 | 31 | 21 | 13 |
| R11x99 | 14 | M | 57 | 32 | 133 | 81 | 55 | 34 |
| R11x99 | 14 | H | 29 | 60 | 66 | 40 | 27 | 17 |
| R11x139 | 15 | M | 84 | 48 | 198 | 120 | 82 | 51 |
| R11x139 | 15 | H | 42 | 90 | 97 | 59 | 40 | 25 |
| R13x27 | 16 | M | 12 | 9 | 26 | 16 | 11 | 6 |
| R13x27 | 16 | H | 7 | 14 | 14 | 8 | 6 | 3 |
| R13x43 | 17 | M | 27 | 14 | 62 | 37 | 26 | 16 |
| R13x43 | 17 | H | 13 | 28 | 28 | 17 | 12 | 7 |
| R13x59 | 18 | M | 38 | 22 | 88 | 53 | 36 | 22 |
| R13x59 | 18 | H | 20 | 40 | 45 | 27 | 18 | 11 |
| R13x77 | 19 | M | 53 | 32 | 124 | 75 | 51 | 31 |
| R13x77 | 19 | H | 29 | 56 | 66 | 40 | 27 | 17 |
| R13x99 | 20 | M | 73 | 40 | 171 | 104 | 71 | 44 |
| R13x99 | 20 | H | 35 | 78 | 80 | 49 | 33 | 20 |
| R13x139 | 21 | M | 106 | 60 | 251 | 152 | 104 | 64 |
| R13x139 | 21 | H | 54 | 112 | 126 | 76 | 52 | 32 |
| R15x43 | 22 | M | 33 | 18 | 76 | 46 | 31 | 19 |
| R15x43 | 22 | H | 15 | 36 | 33 | 20 | 13 | 8 |
| R15x59 | 23 | M | 48 | 26 | 112 | 68 | 46 | 28 |
| R15x59 | 23 | H | 26 | 48 | 59 | 36 | 24 | 15 |
| R15x77 | 24 | M | 67 | 36 | 157 | 95 | 65 | 40 |
| R15x77 | 24 | H | 31 | 72 | 71 | 43 | 29 | 18 |
| R15x99 | 25 | M | 88 | 48 | 207 | 126 | 86 | 53 |
| R15x99 | 25 | H | 48 | 88 | 111 | 68 | 46 | 28 |
| R15x139 | 26 | M | 127 | 72 | 301 | 182 | 125 | 77 |
| R15x139 | 26 | H | 69 | 130 | 162 | 98 | 67 | 41 |
| R17x43 | 27 | M | 39 | 22 | 90 | 55 | 37 | 23 |
| R17x43 | 27 | H | 21 | 40 | 47 | 28 | 19 | 12 |
| R17x59 | 28 | M | 56 | 32 | 131 | 79 | 54 | 33 |
| R17x59 | 28 | H | 28 | 60 | 63 | 38 | 26 | 16 |
| R17x77 | 29 | M | 78 | 44 | 183 | 111 | 76 | 47 |
| R17x77 | 29 | H | 38 | 84 | 87 | 53 | 36 | 22 |
| R17x99 | 30 | M | 100 | 60 | 236 | 143 | 98 | 60 |
| R17x99 | 30 | H | 56 | 104 | 131 | 79 | 54 | 33 |
| R17x139 | 31 | M | 152 | 80 | 361 | 219 | 150 | 92 |
| R17x139 | 31 | H | 76 | 156 | 178 | 108 | 74 | 46 |

### Finder patterns

Rectangular Micro QR Code has three types of finder pattern:
* Finder pattern$^{:6.3.3}$ on top-left corner with 1X separator on bottom-right space;
* Finder sub pattern$^{:6.3.7}$ in bottom-right corner;
* Possible corner finder patterns$^{:6.3.8}$ on top-right and bottom-left barcode corners.
Main finder pattern is used to detect the barcode on image and its corruption can make barcode unrecognizable.
Finder pattern has vertical and horizontal size 1-1-3-1-1. Finder sub pattern helps to detect bottom-right corner of the barcode. Finder sub pattern does not have guard zone and has vertical and horizontal size 1-1-1-1-1.
Corner finder patterns allows to detect top-right and bottom-left corners and in some version of the rMQR Code can be cut or absent. Corner finder pattern looks like corner with white dot in the center with size 3-3.

### Alignment and timing patterns

Rectangular Micro QR Code has alignment$^{:6.3.6}$ and timing patterns$^{:6.3.5}$ which help to detect misaligned cells damage. Alignment pattern is represented as black rectangle 3X size rounding 1X white dot. Alignment pattern in some versions can be absent and number of alignment patterns depends from version, up to 8 alignment patterns.
Alignment patterns count :
| Width | Alignment patterns count |
| 27 | 0 |
| 43 | 2 |
| 59 | 4 |
| 77 | 4 |
| 99 | 6 |
| 139 | 8 |
Timing patterns boarding the barcode where area is clean from finder and alignment patterns and additionally split the barcode vertically in the area of alignment patterns.

### Format Information

Rectangular Micro QR Code places format information$^{:7.9}$ in the area of finder pattern and finder sub pattern. Format information is built as 18-bit sequence containing 6 data bits, 12 error correction bits calculated using the (18, 6) Extended BCH code. Format information is masked with 011111101010110010 sequence which is placed around finder pattern and 100000101001111011 for finder sub pattern.
Rectangular Micro QR Code (rMQR Code) Format information bits :
| Error correction level | Version indicator | Version indicator | Version indicator | Version indicator | Version indicator | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits | Error correction bits |
| $X_{0}$ | $X_{1}$ | $X_{2}$ | $X_{3}$ | $X_{4}$ | $X_{5}$ | $X_{6}$ | $X_{7}$ | $X_{8}$ | $X_{9}$ | $X_{10}$ | $X_{11}$ | $X_{12}$ | $X_{13}$ | $X_{14}$ | $X_{15}$ | $X_{16}$ | $X_{17}$ |
The first data bit defines error correction level and the second 5 data bits defines version indicator.
Error correction level indicator :
| Error correction level | Binary indicator |
| M | 0 |
| H | 1 |

### Error correction

Rectangular Micro QR Code uses Reed–Solomon error correction$^{:7.5}$ and has two error correction levels M and H which can restore around 15 and 30% of damaged barcode area. All data in the barcode is split into error correction blocks (can be from 1 to 4 blocks) and error correction codewords are added to every block. After this, the blocks are united into single stream.
Error correction levels :
| Error correction level | Recovery capacity % |
| M | 15% |
| H | 30% |
rMQR Code use Reed–Solomon error correction over the finite field $\mathbb {F} _{256}$ or GF(2$^8$), the elements of which are encoded as bytes of 8 bits; the byte $b_{7}b_{6}b_{5}b_{4}b_{3}b_{2}b_{1}b_{0}$ with a standard numerical value $\textstyle \sum _{i=0}^{7}b_{i}2^{i}$ encodes the field element $\textstyle \sum _{i=0}^{7}b_{i}\alpha ^{i}$ where $\alpha \in \mathbb {F} _{256}$ is taken to be a primitive element satisfying $\alpha ^{8}+\alpha ^{4}+\alpha ^{3}+\alpha ^{2}+1=0$. The primitive polynomial is $x^{8}+x^{4}+x^{3}+x^{2}+1$, corresponding to the polynomial number 285, with initial root = 0.

### Data masking and placement

Rectangular Micro QR Code places data in the same way as QR code in two-module wide columns$^{:7.7.3}$ commencing at the lower right corner of the symbol and running alternately upwards and downwards from the right to the left.
Before the placement the data is masked$^{:7.8.2}$ with single type of mask (instead of 8 types in QR Code): $((i/2)+(j/3)){\pmod {9}}=0$, where i is a row position; j is a column position.
Codeword sequence as a single bit stream is placed (starting with the most significant bit) in the two-module wide columns alternately upwards and downwards from the right to left of the symbol. In each column the bits are placed alternately in the right and left modules, moving upwards or downwards according to the direction of placement and skipping areas occupied by function patterns, changing direction at the top or bottom of the column. Each bit shall always be placed in the first available module position.
When the data capacity of the symbol is such that it does not divide exactly into a number of 8-bit symbol characters, the appropriate number of remainder bits (1 to 7) shall be used to fill the symbol capacity. These remainder bits shall always have the value 0 before data masking.

## Encoding

Rectangular Micro QR Code can encode 361 numeric, 219 alphanumeric, 150 bytes and 92 kanji characters in the maximal version R17x139. Additionally, it allows to encode Unicode data with Extended Channel Interpretation feature and encode GS1 data.
rMQR Code can encode data in 8 modes$^{:7.4.1}$ where 4 modes are data encoding modes and 3 modes are indicator modes, like ECI. Also, every encoding sequence must be completed with special Terminator mode.
Mode and Mode indicators for rMQR :
| Mode | Mode indicators (3 bits) |
| Numeric | 001 |
| Alphanumeric | 010 |
| Byte | 011 |
| Kanji | 100 |
| FNC1 | 101 (First position) |
| FNC1 | 110 (Second position) |
| ECI | 111 |
| Terminator (End of message) | 000 |
rMQR Code usually encodes data in mixed mode$^{:7.4.7}$ which is a combination of existing modes for better compactification or special selectors like ECI designator.
rMQR Mixed mode encoding :
| Segment 1 | Segment 1 | Segment 1 | ECI header 1 | ECI header 1 | Segment 2 | Segment 2 | Segment 2 | Segment 3 | Segment 3 | Segment 3 | Terminator |
| Mode 1 | Data count | Data | ECI Mode 1 | ECI designator | Mode 2 | Data count | Data | Mode 3 | Data count | Data | Terminator |
Every compaction mode depends on version$^{:7.4.1}$ to select number of bits which are used as encoded characters (numbers, letters, bytes) counter. The number of bits required for every version can be watched in the following table.
Number of bits of character count indicator :
| Version | Numeric mode | Alpha mode | Byte mode | Kanji mode | Version | Numeric mode | Alpha mode | Byte mode | Kanji mode |
| R7x43 | 4 | 3 | 3 | 2 | R13x27 | 5 | 5 | 4 | 3 |
| R7x59 | 5 | 5 | 4 | 3 | R13x43 | 6 | 6 | 5 | 5 |
| R7x77 | 6 | 5 | 5 | 4 | R13x59 | 7 | 6 | 6 | 5 |
| R7x99 | 7 | 6 | 5 | 5 | R13x77 | 7 | 7 | 6 | 6 |
| R7x139 | 7 | 6 | 6 | 5 | R13x99 | 8 | 7 | 7 | 6 |
| R9x43 | 5 | 5 | 4 | 3 | R13x139 | 8 | 8 | 7 | 7 |
| R9x59 | 6 | 5 | 5 | 4 | R15x43 | 7 | 6 | 6 | 5 |
| R9x77 | 7 | 6 | 5 | 5 | R15x59 | 7 | 7 | 6 | 5 |
| R9x99 | 7 | 6 | 6 | 5 | R15x77 | 8 | 7 | 7 | 6 |
| R9x139 | 8 | 7 | 6 | 6 | R15x99 | 8 | 7 | 7 | 6 |
| R11x27 | 4 | 4 | 3 | 2 | R15x139 | 9 | 8 | 7 | 7 |
| R11x43 | 6 | 5 | 5 | 4 | R17x43 | 7 | 6 | 6 | 5 |
| R11x59 | 7 | 6 | 5 | 5 | R17x59 | 8 | 7 | 6 | 6 |
| R11x77 | 7 | 6 | 6 | 5 | R17x77 | 8 | 7 | 7 | 6 |
| R11x99 | 8 | 7 | 6 | 6 | R17x99 | 8 | 8 | 7 | 6 |
| R11x139 | 8 | 7 | 7 | 6 | R17x139 | 9 | 8 | 8 | 7 |

### Numeric mode

Rectangular Micro QR Code encodes digits 0–9 in numeric mode.$^{:7.4.3}$ The number sequence is split into 3 digits which converted to 10 bits (000 - 999). Last 2 and 1 numbers are encoded in 7 and 4 bits. rMQR Code in numeric mode encodes 001 as mode indicator, then numbers counter and then numbers sequence converted into bits.
Numeric mode encoding :
| Numbers count | Bits count | Value | Bits |
| 3 | 10 | 734 | 1011011110 |
| 3 | 10 | 001 | 0000000001 |
| 2 | 7 | 72 | 1001000 |
| 1 | 4 | 5 | 00101 |

### Alphanumeric mode

Rectangular Micro QR Code encodes 2 alphanumeric characters$^{:7.4.4}$ from the table into 11 bits stream with the following formula: $V=45*C_{1}+C_{2}$
Encoding/decoding table for alphanumeric mode :
| Value | Character | Value | Character | Value | Character | Value | Character | Value | Character |
| 0 | 0 | 9 | 9 | 18 | I | 27 | R | 36 | Space |
| 1 | 1 | 10 | A | 19 | J | 28 | S | 37 | $ |
| 2 | 2 | 11 | B | 20 | K | 29 | T | 38 | % |
| 3 | 3 | 12 | C | 21 | L | 30 | U | 39 | * |
| 4 | 4 | 13 | D | 22 | M | 31 | V | 40 | + |
| 5 | 5 | 14 | E | 23 | N | 32 | W | 41 | - |
| 6 | 6 | 15 | F | 24 | O | 33 | X | 42 | . |
| 7 | 7 | 16 | G | 25 | P | 34 | Y | 43 | / |
| 8 | 8 | 17 | H | 26 | Q | 35 | Z | 44 | : |
Final character is encoded into 6 bits. rMQR Code in alphanumeric mode encodes 010 as mode indicator, then alphanumeric counter and then bits stream which represents encoded characters.

### Byte mode

Rectangular Micro QR Code adds mode indicator 011 and bytes counter (version dependent) before the byte stream,$^{:7.4.5}$ converted into 8-bit sequence.

### Kanji mode

Rectangular Micro QR Code encodes characters from 2 bytes JIS X 0208 2-byte character set$^{:7.4.6}$ into 13 bits with the following rules:
* For characters with Shift JIS values from 0x8140 to 0x9FFC:
* subtract 0x8140 from Shift JIS value;
* multiply most significant byte of result by 0xC0;
* add least significant byte to product from step 2;
* convert result to a 13-bit binary string.
* For characters with Shift JIS values from 0xE040 to 0xEBBF:
* subtract 0xC140 from Shift JIS value;
* multiply most significant byte of result by 0xC0;
* add least significant byte to product from step 2;
* convert result to a 13-bit binary string.
rMQR Code adds mode indicator 100 and characters counter before the encoded kanji sequence.

### Unicode encoding with ECI

Rectangular Micro QR Code encodes Unicode characters with Extended Channel Interpretation.$^{:7.4.2.2}$ Previously it encodes ECI designator which defines encoding charset. After this, it encodes byte array of Unicode characters encoded into byte stream with mix of numeric-text-byte modes. The default ECI designator is \000003(ISO/IEC 8859-1).
ECI designator is encoded with mode indicator 111 and ECI assignment number which can be encoded in 8, 16 or 24 bits by rules from the following table.
Encoding ECI assignment number :
| ECI assignment value | Codewords count | Codeword values |
| 000000 to 000127 | 1 | 0bbbbbbb |
| 000000 to 016383 | 2 | 10bbbbbb bbbbbbbb |
| 000000 to 999999 | 3 | 110bbbbb bbbbbbbb bbbbbbbb |
| where b ... b is the binary value of the ECI Assignment number |||

### GS1 encoding

Rectangular Micro QR Code can encode GS1 Data with FNC1 in first position.$^{:7.4.8.2}$ Encoding mode indicator 101 switch the barcode symbol in GS1 Application Identifiers mode. FNC1 cannot be used as split FNC1 character like in Code 128 symbol. Instead of this, % character should be used in alphanumeric mode or GS (0x1D) in byte mode. To encode % character in alphanumeric mode the character should be doubled %% and after decoding it should be transmitted as single % character.

### FNC1 in second position

FNC1 in second position$^{:7.4.8.3}$ at this time has historical value and is not used. It was used to encode (obsolete at this time) mode identifier as first data codeword in Code 128 when FNC1 character is encoded in the second codeword (second position). More detail description you can read in ISO/IEC 15417 Annex B.
Rectangular Micro QR Code encodes FNC1 in second position as mode indicator 111, 8-bit application identifier (AIM, but I am not sure) and any other mode/modes after this.