i need to compress an array of chars, so that my new data will be written to a binary file, with only the first 5 bits of each byte.

if i have an array of
Code:
{1,2,3}
i want to write to my binary file:
00001 00010 00011 (without the spaces of course)

can someone tell me a good way of doing that?

thanks