串来串COM pression算法? [英] String to string compression algorithm?

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

问题描述

我在寻找一种算法,将COM preSS一些字符串到另一个字符串(即没有\ 0或特殊控制字符),但我不能在互联网上找到任何东西。有没有这样的算法?它并不必须是特别有效的,只是一些基本

I'm looking for an algorithm that would compress some string to another string (i.e. without "\0" or special control characters), but I can't find anything on the internet. Is there such an algorithm? It doesn't have to be particularly efficient, just something basic.

推荐答案

显然,你有一些特殊字符的思维定势,你想用它为原始字符串和COM pressed字符串。

Apparently you have some specific character set in mind and you want to use it for both the original string and the compressed string.

标准COM pression程序(如 GZIP )的字节串的工作。

Standard compression routines (e.g. gzip) work on byte strings.

一个想法是利用现有的code(如gzip压缩的),并重写,使其能够使用的字符集 而不是字节

One idea is to take existing code (e.g. gzip's) and rewrite it to use your character set instead of bytes.

另外一种是使用标准的COM pression构建你的字符集的字符串和任意字节串之间的1对1的映射,映射原始的字符串和字节串,玉米preSS的字节串实用程序或功能,且结果映射回使用的字符集的字符串。 (严格的说,你可以使用两种不同的映射。)

Another is to construct a 1-to-1 mapping between strings in your character set and arbitrary byte strings, map the original string to a byte string, compress the byte string using a standard compression utility or function, and map the result back to a string using your character set. (Strictly speaking you can use two different mappings.)

来构造映射的一种方法是垫的字符集与假人和一个特殊的填充字符,直到你有2 ^ k个不同的字符(某个k);那么你的角色每8对应k字节为单位(和更短的字符串可以用填充字符进行填充)。

One way to construct the mapping is to pad your character set with dummies and a special pad character until you have 2^k different characters (for some k); then each 8 of your characters correspond to k bytes (and shorter strings can be padded with the pad character).

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

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