通过在 PHP 中转换它的基数来压缩小字符串?
我想知道是否有某种方法可以通过组合一些本机 PHP 压缩和基本转换函数来压缩一个小的 ASCII 字符串(~100 个字符),以生成一个更小的字符串(`~60 个字符)。
例如,我可以采用一个字符串, gzcompress 它,将其转换为数字,然后将基数更改为具有更多值的系统?
目标是拥有一个更小的 ASCII(可能是 UTF-8)兼容显示的字符串。
I was wondering if there would be some way to compress a small ASCII string (~100 characters) by combining some of the native PHP compression and base converting functions to produce an even smaller string (`~60 characters).
For example, could I take a string, gzcompress it, convert it to a number, and then change the base to a system with more values?
The goal is to have a smaller string that is ASCII (perhaps UTF-8) compatible for display.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试像 lzw 或 golomb 代码这样的字典压缩,但压缩取决于数据。没有确切的数据就无法回答这个问题。
You could try a dictionary compression like lzw or a golomb code but the compression depends on the data. Without the exact data it's not possible to answer the question.
应该可以,但我不认为这会让你的原始字符串变得更小。
That should do it, but I don't think this will make your original string much smaller.