From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Assembling Complex Strings Containing Carriage Returns Prior to Using Ada.Text_IO.Put? Date: Thu, 23 Oct 2014 18:35:34 -0700 Organization: None to speak of Message-ID: References: <7c1b89e6-9ab8-4faa-b60c-c5c4683f0bff@googlegroups.com> <87d29kfwip.fsf@ludovic-brenta.org> <16xum8oxn75uu.gepkhyd81ykl.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="12131"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194iMVUvIhjrirJ1LQFtN+F" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:gG96etfQyEL56667aM1sFYca+Fg= sha1:Mkx3oWcAdqV41pO2m+kRt1yFZPY= Xref: news.eternal-september.org comp.lang.ada:22692 Date: 2014-10-23T18:35:34-07:00 List-Id: "Dmitry A. Kazakov" writes: > On Wed, 22 Oct 2014 07:36:32 -0700 (PDT), Maciej Sobczak wrote: >>> '\n' is not ASCII.CR, it is ASCII.LF, by the way. And on some >>> nonstandard platforms, the C compiler translates '\n' into a sequence of >>> two characters, ASCII.CR & ASCII.LF. >> >> What are those nonstandard platforms where the C compiler translates a >> single character '\n' into a sequence of two characters? > > Maybe I/O library was meant? E.g. when opening file in text mode with fopen > LF will be translated into CR-LF on Windows, or into the physical record > end on VMS. Yes. Specifically, that mapping occurs when writing to an output stream in text mode. The reverse translation happens when reading from an input stream in text mode. >> In particular, what happens in the following statement: >> >> const char c = '\n'; That sets c to the value of '\n', which is a single byte. It typically has the value 10, which is the ASCII code of the LF character (but C doesn't specify ASCII, so it could be something else). > Considering some crazy platform where char is 2-bytes long, one could say > that C compiler would translate '\n' and all other characters into two > "proper" characters. In C, the type char is exactly one byte. That's the definition of the word "byte" in C. The constant CHAR_BIT specifies the number of bits in a byte; it's required to be at least 8 (and is usually exactly 8). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"