COM pressing UTF-8(或其他8位编码),以7位或更少位 [英] Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits

查看:121
本文介绍了COM pressing UTF-8(或其他8位编码),以7位或更少位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要借此以UTF-8的文件连接codeD,不使用超过128个不同的字符,然后将其移动到7位编码以节省空间的1/8。举例来说,如果我有只使用第128(ASCII)字符的16 MB的文本文件,我想刮掉多余的位,以减少文件到14MB。

I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.

我怎么会去这样做?

似乎没有成为一个现有的免费或专有程序这样做,所以我想我可能会尝试做一个简单(如果低效)之一。

There doesn't seem to be an existing free or proprietary program to do so, so I was thinking I might try and make a simple(if inefficient) one.

的基本思想我必须是使从当前进制/十进制/二进制用于每个字符的128个值我会在七个位编码值的函数,则通过文件扫描和写入每个修改值至一个新的文件。

The basic idea I have is to make a function from the current hex/decimal/binary values used for each character to the 128 values I would have in the seven bit encoding, then scan through the file and write each modified value to a new file.

因此​​,如果文件看起来像(我将使用一个小数点的例子,因为我尽量不要有想在十六进制)

So if the file looked like(I'll use a decimal example because I try not to have to think in hex)

127 254 025 212 015 015 132 ...
这将成为

127 254 025 212 015 015 132... It would become

001 002 003 004 005 005 006

001 002 003 004 005 005 006

如果127映射到001,254映射为005,等等。

If 127 mapped to 001, 254 mapped to 005, etc.

我不是一对夫妇的事情完全肯定,但。

I'm not entirely sure on a couple things, though.


  1. 这是否足以真正缩短了文件大小?我有一种不好的预感,这将只是对二进制字符串留下一个额外的0 - 11011001可能会被映射到01000001,而不是1000001,我不会真正节省空间。
    如果这会发生​​,我该如何摆脱零?

  2. 如何打开文件读取二进制/十进制/十六进制/写,而不仅仅是文字?
    我大部分时间与Python的工作,但如果我要,我可以通过C语言蒙混过关。

感谢您。

推荐答案

只需使用gzip的COM pression,并节省60-70%与0%的努力!

Just use gzip compression, and save 60-70% with 0% effort!

这篇关于COM pressing UTF-8(或其他8位编码),以7位或更少位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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