Re: Is there a standard way to write an 8 bit byte?
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: 2 May 2005 20:58:31 GMT
In article <ZWvde.166$Rl4.127@xxxxxxxxxxxxxxxxxxxxxxx>,
Kristian Nybo <kristian@xxxxxxxxxxxxxxxxxx> wrote:
>I'm writing a simple image file exporter as part of a school project,
>and I would like to write completely platform-independent code if at all
>possible.
PBM -- Portable BitMap (monochrome)
PNG -- Portable Network Graphics (colour, lossless compression)
>The problem I've run into is that apparently there's no
>guarantee that a particular implementation will have a data type that is
>exactly 8 bits wide; char is only guaranteed to be at least 8 bits.
>Correct me if I'm wrong, but I assume that if CHAR_BIT happens to be,
>say, 9, writing a char into a file in binary mode would result in 9 bits
>being written.
Yes -- but what happens when you take that file to an 8-bit machine
is undefined. Very few filesystems (none I -know- of) store files
as bitstreams: they are byte or word streams. Ethernet is bitstream,
but most well-known file-transfer protocols involve 8-bit characters.
--
Ceci, ce n'est pas une idée.
.
- Follow-Ups:
- Re: Is there a standard way to write an 8 bit byte?
- From: Kristian Nybo
- Re: Is there a standard way to write an 8 bit byte?
- References:
- Is there a standard way to write an 8 bit byte?
- From: Kristian Nybo
- Is there a standard way to write an 8 bit byte?
- Prev by Date: Re: memset
- Next by Date: Re: Checking if socket is still open?
- Previous by thread: Is there a standard way to write an 8 bit byte?
- Next by thread: Re: Is there a standard way to write an 8 bit byte?
- Index(es):
Relevant Pages
|