编码/压缩使字符串长度变短。 [英] Encoding/Compression to make string length short.

查看:1504
本文介绍了编码/压缩使字符串长度变短。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想将一个字符串编码为16个字符串,该字符串由不同的数字组成,如下所示(A,B,C等...)并且它也应该是可解码的,所以得到所有的信息。



例如:

A = 0到99999之间的任何数字(21923) )

B = 0到99999之间的任何数字(12045)

C = 0到99999之间的任何数字(29433)

D =任何0到99999之间的数字(12003)

E = 0到99999之间的任何数字(234)

F =介于0到99999之间的任何数字(189)





J = 0到99999之间的任何数字(189)



这个可以达到J.但G,H,I和J是可选的。



Z = A#B#C#D#E#F

Z = 21923#12045#29433#12003#234#189



现在对字符串Z执行任何编码操作,结果字符串要保持最多16字符,它应该是可解码的,所以能够获得ab ove all part(例如。 A,B,C等...)与分配相同。



此外,结果字符串应仅包含0-9且字母(AZ)的大写字符



我试图将每个部分(例如A,BC等)转换为十六进制数并使其具体化,但我无法将长度限制为16个字符这是可以反向解码以获取原始信息。



所以任何人都可以帮助我或暗示实现这一点。



谢谢,

Hello,

I want to encode one string to 16 character string which is composite from different numeric digits as below (A, B, C etc..) and it should be decodable also so get all the information back.

For example :
A = any number between 0 to 99999 (21923)
B = any number between 0 to 99999 (12045)
C = any number between 0 to 99999 (29433)
D = any number between 0 to 99999 (12003)
E = any number between 0 to 99999 (234)
F = any number between 0 to 99999 (189)
.
.
J = any number between 0 to 99999 (189)

This can be possible upto J. but G, H, I and J are optional.

Z = A#B#C#D#E#F
Z = 21923#12045#29433#12003#234#189

Now by doing any encode operation on string Z, result string want to maintain upto 16 characters and it should be decodable so able to get the above all part (eg. A, B, C etc...) same as it is assigned.

Also Result string should be contain only 0-9 and capital character of Alphabet (A-Z)

I have tried to convert each part (eg. A, B C etc .) to Hex number and conctate it but I am not able to restrict the length upto 16 character which is reverse decodable to get original information.

so can any one help me or give hint to achieve this thing.

Thanks,

推荐答案

请看我对这个问题的评论。



也考虑这个:不是每个字符串都可以压缩成16个字符的字符串。那些不值得压缩的东西。此外,即使你压缩某些东西,压缩因子也是非常小的。您甚至可以使压缩字符串比未压缩字符串占用更多内存。总的来说,它完全没有意义。



-SA
Please see my comment to the question.

Also consider this: not every string can be compressed to 16-character string. And those which can does not deserve to be compressed. Besides, even if you "compress" something, compression factor is ridiculously small. You can even make "compressed" string taking up more memory than uncompressed. Overall, it makes no sense at all.

—SA


这篇关于编码/压缩使字符串长度变短。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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