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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.111.131 with SMTP id ii3mr19762579igb.6.1413958834934; Tue, 21 Oct 2014 23:20:34 -0700 (PDT) X-Received: by 10.140.85.212 with SMTP id n78mr2408qgd.21.1413958834797; Tue, 21 Oct 2014 23:20:34 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!h18no8627233igc.0!news-out.google.com!u5ni10qab.1!nntp.google.com!cm18no240531qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 21 Oct 2014 23:20:34 -0700 (PDT) In-Reply-To: <7c1b89e6-9ab8-4faa-b60c-c5c4683f0bff@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.37.248.239; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 NNTP-Posting-Host: 93.37.248.239 References: <7c1b89e6-9ab8-4faa-b60c-c5c4683f0bff@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Assembling Complex Strings Containing Carriage Returns Prior to Using Ada.Text_IO.Put? From: mockturtle Injection-Date: Wed, 22 Oct 2014 06:20:34 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:22652 Date: 2014-10-21T23:20:34-07:00 List-Id: On Wednesday, October 22, 2014 7:57:39 AM UTC+2, NiGHTS wrote: > I am converting some code from C to Ada which involves building a complex string containing '\n' characters which would eventually be displayed on the standard output console using the printf() function. > > > > I tried to copy the same strategy of building the string in Ada like this: > > > > > > Complex_String : Ada.Strings.Unbounded.Unbounded_String; > > EOL : String := ASCII.CR'Img; > > > > ... > > > > Ada.Strings.Unbounded.Append (Complex_String, > > "Menu Title" & EOL & > > "-------------------------------------" & EOL > > ); > > > > ... > > > > Ada.Text_Io.Put ( > > Ada.Strings.Unbounded.To_String( Complex_String ) ); > > Instead of breaking the line in the places where EOL has been inserted, it seems to show the letters "CR" in its place. > > The searches I performed on Google seem to be void of any hints on how to get this working. I can't imagine that I am the only one with this requirement in Ada. > > Thanks in advance for your advice. Do not use 'Img (that, by the way, I guess it is a GNAT extension). Just do this EOL : String := "" & ASCII.CR; or this EOL : String(1..1) := (1 => ASCII.CR); These funny syntaxes are necessary if you want EOL to be a string, since CR is a character. I think that in your case this would work too EOL : constant Character := ASCII.CR;