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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,60973b026c6e423d X-Google-Attributes: gid103376,public From: George Haddad Subject: Re: help: character to integer Date: 1996/10/02 Message-ID: <3252BEC8.529E@lmco.com>#1/1 X-Deja-AN: 186745666 references: <52s2pl$18l@dailyplanet.wam.umd.edu> <52t8la$2l8@goanna.cs.rmit.edu.au> content-type: text/plain; charset=us-ascii organization: Lockheed Martin M & S, Sunnyvale, CA mime-version: 1.0 reply-to: george.haddad@lmco.com newsgroups: comp.lang.ada x-mailer: Mozilla 2.02 (Macintosh; I; PPC) Date: 1996-10-02T00:00:00+00:00 List-Id: Richard A. O'Keefe wrote: > spear@wam.umd.edu (Eric Anthony Spear) writes: > >Is there a function, either in a package or as an attribute, that can > >work like this BASIC function: > >i = ASC("X") > >That is, the function returns the ASCII value of the given character. > > Values of any discrete type can be converted to integers using the > 'Pos attribute and back again using the 'Val attribute. This was so > in Ada 83 and is still so in Ada 95. You want > > I := Character'Pos('X'); Forgive my ignorance, but is there any guarantee that Character'POS('X') = {ASCII code for 'X'}? Especially now that Ada uses ISO Latin-1 (or whatever the standard actually calls for). Are ASCII and Latin-1 two names for the same standard? (I assume that they are at least equivalent for "well-behaved" characters as the solution probably works empirically.) That having been said, it would obviously be easy to convert between the two by providing a lookup table. -- I found these opinions on my doorstep, would you please give them a good home?