如何压缩字符串? [英] How to compress a string?

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

问题描述

我想对一种类型的字符串进行可逆压缩,以便我可以将其包含在URL中,而不跟踪它的引用。我想压缩的字符串是SVG路径字符串,这里是一个短的引物: http://apike.ca/ prog_svg_paths.html

I would like to have a reversible compression for a type of string so that i can include it in URLs without keeping track of what it refers to. The string i would like to compress is SVG path string, here is a short primer: http://apike.ca/prog_svg_paths.html

基本上,字符串包含一个字符,后跟任意数字的整数,然后是另一个字符后跟任意数字的整数,依此类推。

Basically, the string contains a character, followed by arbitrary number of integers, then another character followed by arbitrary number of integers and so on.

如果任何人都知道有一个好的资源,这将是非常感激。

If anyone knows of a good resource for this, it would be much appreciated!

Jason

推荐答案

许多压缩算法都有详细的文档,一对夫妇甚至有js实现:

Many compression algorithms are well documented, a couple even have js implementations:


  • GZip 常见(合理)良好的压缩算法,我知道有一个JS植入,我只是寻找URL

  • GZip A common (reasonably) good compression algorithm, I know there's a JS impl, i'm just hunting the URL

LZW 另一个问题指向JS中的LZW实现

LZW Another question points to an LZW implementation in JS

算术编码(我这样做,但它使用的模型是愚蠢的,所以没有达到它最好的压缩率)

Arithmetic coding (i did this, but the model it uses is stupid so doesn't achieve the best compression rates it could)

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

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