- Decimal vs Base64 in QR Codes: Encoding data in decimal uses many more characters than base64 (e.g.,
06513249
vsYWJj
), but is better for QR codes. QR modes store data efficiently, making extra decimal digits almost seem like no encoding. Decimal encoding leads to QR codes that store more data or are easier to scan. - QR Code Examples: Two QR codes show that a base64-encoded QR code (left, version 16) is slightly denser than a decimal-encoded QR code (right, version 14). The larger modules of the decimal QR make scanning easier. In Australia's COVID contact-tracing QR codes, NSW used a 228-character base64-encoded URL, which can be encoded into an 81×81 QR code. Rewriting it in decimal reduces its length to 353 characters and fits into a 73×73 QR code, which is easier to scan.
- Encoding Schemes: There are many ways to encode arbitrary bytes, including base64, base10 (decimal), and base45. Base64 is common but inefficient for QR codes. Base10 treats bytes as a base-256 integer and prints it in base 10. The "input:output ratio" shows the number of output characters needed per input character.
- QR Modes: QR codes store data in a bitstream with different modes. Numeric mode supports 0–9 and has an overhead of 0.34%. Alphanumeric mode supports more characters with an overhead of 0.15%. Binary mode supports arbitrary bytes with 0% overhead. Kanji mode has a very low overhead. Clever choice of modes allows efficient storage.
- Decimal in QR Codes: For base64, 3 input bytes are stored as 4 characters in Binary mode, wasting 75% of values. For base10, each input byte requires about 8.027 bits to store, with an overhead of 0.34% and no overhead in the binary-to-text encoding step.
- Putting it All Together: A URL with base64-encoded JSON can be encoded better in decimal. Decoding the JSON and using the
b10encode
function gives a long decimal number. In a URL, using two segments (one with "boring" bits in Binary mode and one with decimal data in Numeric mode) is possible. NSW COVID check-in QR codes show the difference between base64 and base10. - Extremes: Being clever with modes and encodings allows reaching the limits of the QR code format. Version 40 with error correction level L can store up to 3.0 KB. Base10 can fit more data than base64url, but iOS may have issues scanning very long base10 URLs.
- Summary: Paying attention to QR code details allows efficiency. Using Decimal mode to store binary data in URLs with minimal overhead is the trick. It allows reducing QR code density or jamming in more data.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。