By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,677 Members | 1,272 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,677 IT Pros & Developers. It's quick & easy.

trade off by using Base64 encoding

P: n/a
Hi,
I ma thinking whether to use Base64 encoding to encode the binary
content in the XML file. I have done some simple calculations, it
seems to me that the size for encoded content increases by ~30%, is
this the drawback for using the encoding scheme?
Thanks.
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
By my math, you will use 32 bits for every 24 encoded (4 base64 characters
(bytes) for 3 octets (bytes) worth of bits, or exactly 1-1/3 times the
space required for the raw bits.

Since there's no commonly-available, safe alternative for carrying binary
data in XML elements, I suppose you should be asking "drawback relative to
what?"

(If the binary is compressible, you might do that before Base64 encoding.
But that adds more to what the recipient is required to do.)

-- orcmid

"wenmang" <we*****@yahoo.com> wrote in message
news:9f**************************@posting.google.c om...
Hi,
I ma thinking whether to use Base64 encoding to encode the binary
content in the XML file. I have done some simple calculations, it
seems to me that the size for encoded content increases by ~30%, is
this the drawback for using the encoding scheme?
Thanks.

Jul 20 '05 #2

P: n/a
"Dennis E. Hamilton" <de*************@acm.org> wrote in message news:<82******************************@news.terane ws.com>...
By my math, you will use 32 bits for every 24 encoded (4 base64 characters
(bytes) for 3 octets (bytes) worth of bits, or exactly 1-1/3 times the
space required for the raw bits. I am on HPUX11, could I use 4 base64 chars to encode 4 octets? is this
doable or 1-1/3 ratio is always the case?
Since there's no commonly-available, safe alternative for carrying binary
data in XML elements, I suppose you should be asking "drawback relative to
what?" I use a wrong word, I should ask "is the price to pay for encoding the
binary content?"
I am wondering whether 1 to 1 byte to byte encoding is possbile using
base64 for binary encoding without incurring the increasing in size?
(If the binary is compressible, you might do that before Base64 encoding.
But that adds more to what the recipient is required to do.)

-- orcmid

Jul 20 '05 #3

P: n/a
In Base 64 encoding, there are only 64 characters used per octet (not
counting white space and other things that don't count). That gives you 6
bits of encoded material. The only way to encode 24 bits of material (3
full octets) is with 4 Base 64 characters. You will always use 4 octets to
encode 3.

The whole reason for this is to be able to use a channel that will likely
preserve those 64 different character encodings, in traveling end-to-end,
without loss or disruption. That's the price. The machine and operating
system you are on has nothing to do with it.

-- orcmid

"wenmang" <we*****@yahoo.com> wrote in message
news:9f**************************@posting.google.c om...
"Dennis E. Hamilton" <de*************@acm.org> wrote in message

news:<82******************************@news.terane ws.com>...
By my math, you will use 32 bits for every 24 encoded (4 base64 characters (bytes) for 3 octets (bytes) worth of bits, or exactly 1-1/3 times the
space required for the raw bits.

I am on HPUX11, could I use 4 base64 chars to encode 4 octets? is this
doable or 1-1/3 ratio is always the case?
Since there's no commonly-available, safe alternative for carrying binary data in XML elements, I suppose you should be asking "drawback relative to what?"

I use a wrong word, I should ask "is the price to pay for encoding the
binary content?"
I am wondering whether 1 to 1 byte to byte encoding is possbile using
base64 for binary encoding without incurring the increasing in size?

(If the binary is compressible, you might do that before Base64 encoding. But that adds more to what the recipient is required to do.)

-- orcmid

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.