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: border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Convert a Wide_String (or a Wide_Character) to an Integer. Date: Tue, 10 Feb 2015 14:38:24 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <19fa66d7-91ac-4196-9c8f-c633950b9e39@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 10 Feb 2015 21:37:50 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e4b4b8b581459d4904f1a14c474a248f"; logging-data="17425"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XH46kQS2NhxHlRVyYSvdc2w25EhDZRBQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: <19fa66d7-91ac-4196-9c8f-c633950b9e39@googlegroups.com> Cancel-Lock: sha1:RwLSX+jF1sIRS3+bGCZEfd5z138= Xref: number.nntp.giganews.com comp.lang.ada:192242 Date: 2015-02-10T14:38:24-07:00 List-Id: On 02/10/2015 02:16 PM, lomoscompany@gmail.com wrote: > Why does it have to be so damn complicated? It isn't. > How does one convert a Wide_String into a normal String? Or, in my case, a Wide_Character to a Character. The package Ada.Characters.Conversions defines functions To_Character, which convert a [Wide_]Wide_Character to Character. There are also similar To_String functions. See ARM A.3.4: http://www.adaic.org/resources/add_content/standards/12rm/html/RM-A-3-4.html Anyone using Ada should be familiar with the contents of ARM Annex A, which defines the standard library. > -- NEED TO RETURN AN INTEGER CREATED FROM A SINGLE CHARACTER IN A WIDE > -- STRING HERE To convert a single character to an integer value presumes that the character is a digit. That can be converted more simply with Character'Pos (Char) - Character'Pos ('0') Presuming that the digits are contiguous beginning with '0' for Wide_Character, this would work with Wide_Character'Pos as well. -- Jeff Carter "Spam! Spam! Spam! Spam! Spam! Spam! Spam! Spam!" Monty Python's Flying Circus 53