• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

After encoding data size is increasing

 
Siddesh Basapura
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

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
 
Henry Wong
author
Marshal
Pie
Posts: 21431
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siddesh Bm wrote:
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?


That's how base64 encoding works... it takes bytes which has 256 possible values and limits them to only 64 possible values (plus one or two for control purposes). These values are limited to the ASCII printable range, and hence, can pass through systems that will choke on binary data.

So what happens when 8 bits of a byte must fit into bytes that effectively only has 5 bits ? Obviously, you need more bytes.

Henry
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
encoding is NOT the same thing as compression, as you probably know.

Base64 is often used on binary data that needs to be transmitted across a system that isn't really designed for binary. Depending on what you're doing, you may not even need to encode it. And per the wikipedia, on average, a file is expected to grow about 37% when you base64 encode it, which is almost exactly what your numbers are.
 
Siddesh Basapura
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Thanks for the replay.
Now i come to know how BASE64 encoder will works by looking you replay and after gone through the wiki link "http://en.wikipedia.org/wiki/Base64#Examples".


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic