Base91,如何计算? [英] Base91, how is it calculated?

查看:189
本文介绍了Base91,如何计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上寻找basE91的计算方法.我找到了诸如之类的资源,该资源指定了用于特定值的字符,但是我从哪里找不到我得到那个值.

I've been looking online to find out how basE91 is calculated. I have found resources such as this one which specifies the characters used for a specific value but nowhere have I found how I get that value.

我尝试将输入值更改为二进制,并同时获取6位和7位的块,但是它们不起作用,并且得到了错误的输出.我不想自己编写自己的代码,只想知道将字符串编码为basE91所需的过程.

I have tried changing the input values into binary and taking chunks of both 6 and 7 bits but these do not work and I get the incorrect output. I do not want code that will do this for me as I which to write that myself, I only want to know the process needed to encode a string into basE91.

推荐答案

首先,您需要将输入视为位流.

First, you need to see the input as a bit stream.

然后,从流中读取13位,并从中形成一个整数值.如果该整数的值小于或等于88,则再读取一位,并将其放入整数的第14位(最低位为1st).这个整数(叫作v)的最大值是:8192 + 88 = 8280.

Then, read 13 bits from the stream, and form an integer value from it. If the value of this integer is lower than or equal to 88, then read one additional bit, and put it into the 14th bit (lowest bit being 1st) of the integer. This integer's (let's call it v) maximum value is: 8192+88 = 8280.

然后将v分为两个索引:i0 = v%91i1 = v/91.然后使用一个91元素的字符表,并输出两个字符:table[i0]table[i1].

Then split v into two indices: i0 = v%91, i1 = v/91. Then use a 91-element character table, and output two characters: table[i0], table[i1].

(现在您可以看到88的原因:对于最大值(8280),i0i1都变为90)

(now you can see the reason of 88: for the maximal value (8280), both i0 and i1 become 90)

因此,此过程比base64更复杂,但空间效率更高.此外,与base64不同,输出的大小有点取决于输入字节. N长度序列0x00将比N长度序列0xff(其中N是足够大的数字)短.

So this process is more complicated than base64, but more space efficient. Furthermore, unlike base64, the size of the output is a little bit dependent of the input bytes. A N-length sequence of 0x00 will be shorter than a N-length sequence of 0xff (where N is a sufficiently large number).

这篇关于Base91,如何计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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