Encoding 8-bit data into 7-bit streams

  • Thread starter Thread starter rob
  • Start date Start date
R

rob

An existing C# app that uses ascii commands via TCP/IP now needs to
transmit binary data. The current sync mechanism makes use of high
bits, so I'd prefer to simply encode the binary data to 7-bits, and
back at the receiver.

I believe the app can take the performance hit from sacrificing 1 bit
out of 8, but not for encoding as hex ascii.

I know the base code could probably be written easily enough, but
there are a couple logistic corners, so I thought I'd check to see how
others have handled this, and what the options are This seems like
something that would come up fairly often.
 
Actually, base64 is 6 bit. 2^6 = 64. It takes three bytes and pushes
them into four bytes.
 
not_a_commie said:
Actually, base64 is 6 bit. 2^6 = 64. It takes three bytes and pushes
them into four bytes.

Base 64 data has as the name indicates 64 = 2^6 possible values.

But the values chosen needs 7 bit to represent.

Arne
 
rob said:
An existing C# app that uses ascii commands via TCP/IP now needs to
transmit binary data. The current sync mechanism makes use of high
bits, so I'd prefer to simply encode the binary data to 7-bits, and
back at the receiver.

I believe the app can take the performance hit from sacrificing 1 bit
out of 8, but not for encoding as hex ascii.

I know the base code could probably be written easily enough, but
there are a couple logistic corners, so I thought I'd check to see how
others have handled this, and what the options are This seems like
something that would come up fairly often.

Not really.

7 bit went away a couple of decades ago.

But it should be trivial to convert 7 bytes of 8 bit to
8 bytes with only the low 7 bits used for data.

Arne
 
Arne Vajhøj said:
Base 64 data has as the name indicates 64 = 2^6 possible values.

But the values chosen needs 7 bit to represent.

Most systems that don't support 8-bit binary transfer also reserve a few of
the 128 combinations available in 7 bits. So Base-64 is a good solution, it
uses only the subset of 7-bit characters which are printable.
 
Back
Top