编码后数据大小增加 [英] After encoding data size is increasing

查看:63
本文介绍了编码后数据大小增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML格式的文本数据,其长度约为816814字节。它包含一些图像数据以及一些文本数据。
我们使用ZLIB算法进行压缩,压缩后,压缩后的数据长度为487239字节。

I am having a text data in XML format and it's length is around 816814 bytes. It contains some image data as well as some text data. We are using ZLIB algorithm for compressing and after compressing, the compressed data length is 487239 bytes.

压缩后,我们使用BASE64Encoder对数据进行编码。但是在对压缩数据进行编码后,大小会增加,编码数据的长度为666748字节。

After compressing we are encoding data using BASE64Encoder. But after encoding the compressed data, size is increasing and length of encoded data is 666748 bytes.

为什么在编码后数据大小增加了?还有其他最佳编码技术吗?

Why, after encoding data size is increasing? Is there any other best encoding techniques?

问候,
西德什

Regards, Siddesh

推荐答案

如果您的传输介质不是设计用于传输二进制数据,而仅用于传输文本数据(例如XML),则必须执行Base64

Base64 is required to be done, if your transmitting medium is not designed to transmit binary data but only textual data (eg XML)

因此您的zip文件得到了base64编码。

So your zip file gets base64 encoded.

简单地说,它要求代码转换器将非ASCII字母转换为ASCII形式但仍然记得往回走的方法

Plainly speaking, it requires the transcoder to change "non-ASCII" letters into a ASCII form but still remember the way to go back

根据经验,大小增加了约33%( http://en.wikipedia.org/wiki/Base64#Examples

As a rule of thumb, it's around a 33% size increase ( http://en.wikipedia.org/wiki/Base64#Examples )

这是base64的缺点。最好使用支持文件传输的协议...但是对于用XML编码的文件,您几乎没有其他选择。

This is the downside of base64. You are better of using a protocol supporting file-transfer... but for files encoded within XML, you are pretty much out of options.

这篇关于编码后数据大小增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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