[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2 Reference Manual
- From: Axel Kittenberger <axkibe@...>
- Date: Mon, 5 Sep 2011 23:28:11 +0200
Trying to sum it up:
the C- type signed or unsigned "char" is equivalent to a "byte".
A "byte" is at least 8 bits, but does not have to be that. Albeit, de
facto, one can 99%ly assume it is, so far that many started to believe
a byte is always and exactly 8 bits.
The term "octet" jumps in place to be defined to be exactly 8 bits,
but it does not appear anywhere in the C standard(s).
That the term "char" confuses to be char-acter is a little confusing
history from times there weren't ever any multibyte characters.
Lua uses ANSI C (signed) "char". therefore whatever it does, it does "bytes".
PS: Somehow i get a déjà vu feeling on this "what is a char discussion?".
On Mon, Sep 5, 2011 at 11:05 PM, Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Lorenzo Donati once stated:
>>
>> I have only skimmed over Lua source, so I may be utterly wrong, but I
>> got the impression that no assumption is made on a char being 8-bit (it
>> may well be 16-bit and everything would be ok). The only assumption is
>> that a char is *at least* 8-bit.
>>
>> BTW, according to the snippets of the C standards reported by Axel, this
>> assumption may prove wrong, since it seems that the standard doesn't
>> guarantee that a byte or a char can hold at least 8-bit, but this is
>> purely theoretical probably (how many systems nowadays have bytes with 7
>> or less bits? Are there any?)
>
> According the the C89 Standard (I have the ISO C Standard, which only
> differs in section numbering from the ANSI C Standard) section 5.2.4.2.1,
> the *minimum* size of a char is 8 bits. It can be larger. If you need
> chars to be a certain size, you can check the value of CHAR_BIT (number of
> bits in a char) or SCHAR_MAX or UCHAR_MAX.
>
> -spc
>
>
>