编码字符串,以小尺寸QR code代 [英] Encoding strings to small sizes for QRCode generation

查看:294
本文介绍了编码字符串,以小尺寸QR code代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的,可以很容易的长度越长则QR code可以处理字符串生成QR codeS。我在寻找对算法的建议,EN code这些字符串尽可能小,或者证明该字符串不能收缩任何进一步的。

I'm generating QR codes using strings that could very easily be longer in length then a QRCode could handle. I'm looking for suggestions on algorithms to encode these strings as small as possible, or a proof that the string cannot be shrunk any further.

由于我编码一系列项目,我可以重新present他们使用的ID和划定它们使用管道作为在以下查找表:

Since I'm encoding a series of items, I can represent them using ID's and delineate them using pipes as in the following lookup table:

    function encodeLookUp(character){
        switch(character){
            case '0': return '0000';
            case '1': return '0001';
            case '2': return '0010';
            case '3': return '0011';
            case '4': return '0100';
            case '5': return '0101';
            case '6': return '0110';
            case '7': return '0111';
            case '8': return '1000';
            case '9': return '1001';
            case '|': return '1010';
            case ':': return '1011';
        }
        return false;
    }

使用这个表,我已经做了一个基地16编码,因此每个从原来的32串ASCII字符变成半个字符新的字符串(有效减少一半的长度)。

Using this table I am already doing a base 16 encoding, therefore each 32 ascii character from the original string becomes half a character in the new string (effectively halving the length).

Starting String:  01251548|4654654:4465464 // ID1 | ID2 : ID3   demonstrates both pipes.
Bit String:  000000010010010100010101010010001010010001100101010001100101010010110100010001100101010001100100
Result String:  %H¤eFT´FTd // Half the length of the starting string.

那么这个新的ASCII code,根据QR code规范翻译。

Then this new ascii code, is translated according to QRCode specification.

编辑:最数目的字符目前可编码:384

The most amount of characters currently encodable: 384

澄清:两者的ID数字小长度,和ID或管的数量是可变的以相向一种倾向。我期待能够减少这种算法的时候它是一个结果字符串'平均含有最少的字符。

CLARIFICATION: Both ID numberic length, and the quantity of ID's or pipes is variable with a tendancy towards one. I am looking to be able to reduce this algorithm to contain on average the least amount of characters by the time its a 'result string'.

注:该结果字符串是二进制字符串我已经连接$ C $光盘中的数据,以符合标准的QR code规格和读者仅一个ASCII重新presenetaion

NOTE: The result string is only an ascii represenetaion of the binary string i've encoded with the data to conform with standard QRCode specifications and readers.

推荐答案

作为一个开始一个答案,以我自己的问题:

As a start of an answer to my own question:

如果我开始用一串数字

我可以分析该字符串的模式和持有这些patters在那些能够吸收其他4个空格,可以在我的哈夫曼树的特殊符号。

I can parse that string for patterns and hold those patters in special symbols that are able to take up the other 4 spaces available in my Huffman tree.

编辑:例:盯着串12222345,结束串12x345。其中x是一个符号,意思是'重复最后一个符号3次以上

Example: staring string 12222345, ending string 12x345. Where x is a symbol that means 'repeat the last symbol 3 more times'

这篇关于编码字符串,以小尺寸QR code代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆