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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: I need to show extended Ascii codes in GtkAda environment Date: Fri, 22 Nov 2019 15:22:59 -0600 Organization: JSA Research & Innovation Message-ID: References: <5dd7de1b$0$1694$e4fe514c@news.kpn.nl> Injection-Date: Fri, 22 Nov 2019 21:22:59 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="25621"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:57592 Date: 2019-11-22T15:22:59-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:qr8qbp$15gp$1@gioia.aioe.org... > On 2019-11-22 14:09, L Dries wrote: >> In a GtkAda environment I have the need to present some characters or >> strings with characters in the Extended character Ascii range for >> instance O with slash (216). I create a constant character with >> >> Slash_null : constant string(1 .. 1) := "" & character'Val(216); > > GTK is UTF-8. You must encode and decode anything that is not ASCII 7-bit. > [A pragmatic approach is to ignore the reference manual and treat all > strings UTF-8 rather than mandated Latin 1.] > > Anyway, assuming you need the LATIN CAPITAL LETTER O WITH STROKE character > (code point 216), encoded in UTF-8 it is C3 98. Note, two octets. Thus: > > Slash_Null : constant String := > Character'Val (16#C3#) & Character'Val (16#98#); > > With Strings Edit for Ada you could also write: > > Slash_Null : constant String := Strings_Edit.UTF8.Image (216); You could of course use Ada.Strings.UTF_Encoding (a standard part of Ada 2012) to do this as well, by converting the "standard" Latin-1 String to UTF-8: with Ada.Strings.UTF_Encoding.Strings; ... Slash_Null : constant String := Ada.Strings.UTF_Encoding.Strings.Encode (Character'Val(216) & ""); Note that concatenating the character with the null string effectively creates a string with one character. (You could of course use the literal directly if your editor/implementation supports that - tough to do that on the Internet, though.) Randy.