为什么QR码的大写字母小于QR码的质量较低?
Why are QR Codes with capital letters smaller than QR codes with lower case?

原始链接: https://shkspr.mobi/blog/2025/02/why-are-qr-codes-with-capital-letters-smaller-than-qr-codes-with-lower-case-letters/

QR码可以针对尺寸进行优化,并且在编码URL时大写很重要。两个QR码,一个带有“ https://edent.tel/”的QR码,另一个带有“ https://edent.tel/”的QR码,证明了这一点。大写URL生成了较小的QR码(类型1,21x21像素),而小写版本则导致较大的代码(类型2,25x25像素),尽管包含相同的URL并使用相同的低误差校正。 这种差异源于编码模式。大写版本利用字母数字模式,对于大写字母,数字和某些符号等特定字符而言,它更有效。它在接下来的九个位中编码数据长度。小写版本被迫进入字节模式。字节模式的效率低于字母数字模式,因此产生更大的代码,因为字母数字模式仅支持一组有限的字符。通过确保URL完全在大写中,可以创建较小,更有效的QR码。

该讨论围绕QR码编码的效率和实用性,尤其是关于人类可读性和机器可读性的效率和实用性。 OCR-B字体曾经推荐其机器可读性,现在主要以其对人类的知名度而受到重视。 辩论了将URL与QR码一起嵌入URL的想法,重点是用户体验。一项建议建议使用用故意规则构建的简短,令人难忘的URL。 一个关键点是最大化较小尺寸的QR码效率,大写字母数字编码比其他选项受到青睐。有关于编码效率的详细分析,与RFC base45不同意,并认为QR码中的字母数字编码更有效,因为其特定的编码方法。 但是,人们承认存在数字编码可能更有效的边缘案例。最后,讨论建议在QR码中使用大写URL,以便在较小尺寸的情况下更好地扫描性,并以现代智能手机中的QR码扫描功能提高了。
相关文章
  • (评论) 2025-02-27
  • (评论) 2024-08-15
  • (评论) 2024-08-29
  • (评论) 2024-09-12
  • 优秀 URL 设计示例 (2023) 2024-08-15

  • 原文

    Take a look at these two QR codes. Scan them if you like, I promise there's nothing dodgy in them.


    QR CODE   QR Code.


    Left is upper-case HTTPS://EDENT.TEL/ and right is lower-case https://edent.tel/

    You can clearly see that the one on the left is a "smaller" QR as it has fewer bits of data in it. Both go to the same URl, the only difference is the casing.

    What's going on?

    Your first thought might be that there's a different level of error-correction. QR codes can have increasing levels of redundancy in order to make sure they can be scanned when damaged. But, in this case, they both have Low error correction.

    The smaller code is "Type 1" - it is 21px * 21px. The larger is "Type 2" with 25px * 25px.

    The official specification describes the versions in more details. The smaller code should be able to hold 25 alphanumeric character. But https://edent.tel/ is only 18 characters long. So why is it bumped into a larger code?

    Using a decoder like ZXING it is possible to see the raw bytes of each code.

    UPPER

    20 93 1a a6 54 63 dd 28   
    35 1b 50 e9 3b dc 00 ec
    11 ec 11

    lower:

    41 26 87 47 47 07 33 a2   
    f2 f6 56 46 56 e7 42 e7
    46 56 c2 f0 ec 11 ec 11  
    ec 11 ec 11 ec 11 ec 11
    ec 11

    You might have noticed that they both end with the same sequence: ec 11 Those are "padding bytes" because the data needs to completely fill the QR code. But - hang on! - not only does the UPPER one safely contain the text, it also has some spare padding?

    The answer lies in the first couple of bytes.

    Once the raw bytes have been read, a QR scanner needs to know exactly what sort of code it is dealing with. The first four bits tell it the mode. Let's convert the hex to binary and then split after the first four bits:

    Type HEX BIN Split
    UPPER 20 93 00100000 10010011 0010 000010010011
    lower 41 26 01000001 00100110 0100 000100100110

    The UPPER code is 0010 which indicates it is Alphanumeric - the standard says the next 9 bits show the length of data.

    The lower code is 0100 which indicates it is Byte mode - the standard says the next 8 bits show the length of data.

    Type HEX BIN Split
    UPPER 20 93 00100000 10010011 0010 0000 10010
    lower 41 26 01000001 00100110 0100 000 10010

    Look at that! They both have a length of 10010 which, converted to binary, is 18 - the exact length of the text.

    Alphanumeric users 11 bits for every two characters, Byte mode uses (you guessed it!) 8 bits per single character.

    But why is the lower-case code pushed into Byte mode? Isn't it using letters and number?

    Well, yes. But in order to store data efficiently, Alphanumeric mode only has a limited subset of characters available. Upper-case letters, and a handful of punctuation symbols: space $ % * + - . / :

    Luckily, that's enough for a protocol, domain, and path. Sadly, no GET parameters.

    So, there you have it. If you want the smallest possible physical size for a QR code which contains a URl, make sure the text is all in capital letters.

    联系我们 contact @ memedata.com