使用C#压缩字母数字字符串 [英] Compression alpha numeric string using C#

查看:98
本文介绍了使用C#压缩字母数字字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的客户ERP中,他们的产品代码数据输入单元最多只能包含12个字符(字母数字).他们现在正在扩展客户端,并且其产品代码限制已超出限制,并且该字符变为最多30个字符(如果可能的话,可以压缩为35个字符)(字符为字母数字).
例如. A0SALF1525L5LU3GL0FL3657GW1ING仅需要压缩为12个字符,因此可以将其输入或导出到ERP.并在需要时进行检索和解码以获取完整的代码.希望您明白我要寻找的想法,需要编码并减少字符数,然后将它们以编码格式或缩减的字符格式导出到ERP中,并且在需要提取并进行反向或解压缩以取回原始字符串时将其导出.

在此先感谢

Zaki

In my clients ERP they have product code data entry cell has a limits of 12 characters (alpha numeric) only. The client they are now expanding and their product code limit is exceding and it becomes upto 30 (or may 35 if possible solution to compress) character (character are alphanuemric).
eg. A0SALF1525L5LU3GL0FL3657GW1ING this need to be compressed to 12 chars only so it can be entered or exported to ERP. And when needed retrived and decoded to get the full exact the code was. Hope you under stand the idea what I am looking for, need to encode and reduce the number of chars and export them to ERP in encoded format or reducded char format and when need extract and do the reverse or decompresion to get the original string back.

Thanks in advance

Zaki

推荐答案

很难说做到这一点就行了"-我们实际上没有足够的信息.
如果ERP代码接受任何字符,则相当容易-字母数字只有26 + 26 + 10个字符,因此将2个字母数字压缩为1个字符(或将4个字母压缩为1个字符是相当容易的)完整的八位字符).但是,即使那样,您也不能将35个字母数字组合为12个字符(除非您可以使用完整的8位).如果您的产品代码仅为A-Z,即0-9,则可以将3.5个字符压缩为7位,这意味着它可以将35个字符压缩到您的12个字符中.
但是,它取决于您的ERP系统以及它可以接受的有效字符-如果它不能接受除AZ,az,0-9以外的任何内容,那么可用的压缩就很小了,您需要找到另一个系统. br/>
你考虑过翻译表吗? 12个字符可以在AZ,AZ,0-9范围内保存4.7E18个不同的值,我非常怀疑您的客户拥有更多的产品!
It is difficult to say "do this and it''ll work" - we don''t really have enough information.
If the ERP code accepted any character then it is reasonably easy - alphanumeric is only 26+26+10 characters, so it''s fairly easy to compress 2 alphanumeric''s into 1 character (or 4 into 1 if you can use the full eight bit characters). However, even then, you can''t fit 35 alphanumerics into 12 characters (unless you can use the full eight bits). If your product code is only A-Z, 0-9 then it could be compressed 3.5 characters to 7 bits, which would mean it could fit 35 characters into your 12.
However, it is dependant on your ERP system and what it can accept as a valid character - if it can''t accept anything except A-Z, a-z, 0-9 then the available compression is minuscule and you need to find another system.

Have you considered a translation table? 12 characters can hold 4.7E18 different values in the range A-Z, a-z, 0-9 and I seriously doubt that your customer has more products than that!


这篇关于使用C#压缩字母数字字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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