在C中压缩ASCII字符串 [英] Compression of ASCII strings in C

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

问题描述

我有一些C代码,在内存中存储ASCII字符串作为四字节长度,后跟字符串。字符串长度在10-250字节范围内。

I have some C code that stores ASCII strings in memory as a four byte length followed by the string. The string lengths are in the range 10-250 bytes.

为了减少占用,我想在运行时单独压缩每个字符串,仍然存储

To reduce occupancy I'd like to compress each string individually on the fly, still storing the length (of the compressed string) followed by the compressed string.

我不想在比单个字符串更大的范围内进行压缩,因为任何字符串都可以随时读取/写入。

I don't want to compress at a larger scope than individual strings because any string can be read/written at any time.

有什么图书馆/演算法可以做到这一点?

What libraries/algorithms are available for doing this?

感谢您的帮助。
NickB

Thanks for your help. NickB

推荐答案

ZLib 始终在您的服务 - 对于字符串包含不可压缩数据的情况,它是一个很小的开销,它是相对较快,免费的,可以很容易地集成到C和C ++程序。

ZLib is always at your service - it has a very little overhead for the cases when the string contains uncompressable data, it's relatively fast, free and can be easily integrated into C and C++ programs.

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

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