:: Re: [DNG] [OT] [Re: Studying C as t…
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Rainer Weikusat
Date:  
À: dng
Sujet: Re: [DNG] [OT] [Re: Studying C as told. (For help)
Adam Borowski <kilobyte@???> writes:
> On Tue, Jun 21, 2016 at 03:13:21PM +0200, Irrwahn wrote:
>> On Tue, 21 Jun 2016 14:42:46 +0200, Edward Bartolo wrote:
>> [...]
>> >     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
>> [...]
>> You should *never* assume that the latin letters occur in 
>> the execution character set in ascending consecutive order.
>> (Though similar *is* guaranteed for the digits '0' to '9'!)

>
> Not really -- assuming ASCII is like assuming 8-bit bytes[1].


The UNIX(*) standard meanwhile mandates 8-bit bytes,

    3.84 Byte


    An individually addressable unit of data storage that is exactly
    an octet, used to store a character or a portion of a character;
    see also Character. A byte is composed of a contiguous sequence
    of 8 bits.


    http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html


The C standard as mandates continuous encoding of '0' .. '9':

    In both the source and execution basic character sets, the
    value of each character after 0 in the above list of decimal
    digits shall be one greater than the value of the previous.
        [ISO/IEC 9899:1999 (E), 5.2.1|3]


Lastly, if the target system is Linux (as here), one can safely assume
that EBCDIC won't be used.

None of this matter anyhow for solving algorithm exercises in an
entry-level book about a programming language.