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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e710f7d3f890e76b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.uni-stuttgart.de!not-for-mail From: Stefan Bellon Newsgroups: comp.lang.ada Subject: Re: Base64-Encoding Date: Mon, 15 Oct 2007 18:39:19 +0200 Organization: Comp.Center (RUS), U of Stuttgart, FRG Message-ID: <20071015183919.79798fe6@cube.tz.axivion.com> References: <20071015161229.3f439230@cube.tz.axivion.com> <20071015165435.0eef160d@cube.tz.axivion.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: infosun2.rus.uni-stuttgart.de 1192466369 30177 129.69.226.23 (15 Oct 2007 16:39:29 GMT) X-Complaints-To: news@news.uni-stuttgart.de NNTP-Posting-Date: Mon, 15 Oct 2007 16:39:29 +0000 (UTC) X-Newsreader: Sylpheed-Claws 2.6.0 (GTK+ 2.8.20; i486-pc-linux-gnu) X-URL: http://www.axivion.com/ Xref: g2news2.google.com comp.lang.ada:2456 Date: 2007-10-15T18:39:19+02:00 List-Id: On Mon, 15 Oct, Jean-Pierre Rosen wrote: > Stefan Bellon a =E9crit : > > I hoped for this as well, but it looks like the attribute Bit_Order > > is only defined for record types. This is what 13.5.3 says and > > indeed GNAT refuses to accept a 'Bit_Order on Six_Bits or the array > > thereof. >=20 > Bit_Order is about bit numbering, it has nothing to do with endianness Ok, bad wording on my part. Let my try to explain what I mean. The German Wikipedia page for Base64 has a nice coloured illustration: http://de.wikipedia.org/wiki/Base64 My basic idea is to define an array of Six_Bits and "overlay" this at the same address as the String with the usual 8-bit Character encoding. Then iterate over the Six_Bits' array and use the values (which are mod 2**6) to index the Base64_Chars array and build the result buffer. However, when the 1st Byte contains the value Character'Pos('0') =3D 48, I hoped that the first Six_Bits element in the array contained the first 6 bits and thus has a value of 48 / 4 =3D 12. But this is not the case. It has the value 48 as well. In the case of Character'Pos('A') =3D 65, the usual bit value is 2#01000001#, so I had assumed the first Six_Bits element had the value 16 and the second Six_Bits element had the value 16 as well (assuming 0-padding). Data(1) __65__ / \ 010000010000... 010000010000 \____/\____/ 16 16 B64(1) B64(2) But in fact, both Six_Bits elements have the value 1. The fact, that I get 1 in both cases, leads me to the conclusion, that the Six_Bits_Array overlays differently: Data(1) __65__ / \ ...000001000001 000001000001 \____/\____/ 1 1 B64(2) B64(1) When I test this now with two consecutive bytes, I had expected to get: Data(1) Data(2) _129__ _126__ / \/ \ 100000010111111000... \____/\____/\____/ 32 23 56 B64(1) B64(2) B64(3) But what I am seeing is this: B64(1..3) =3D (1, 58, 7) =3D (2#000001#, 2#111010#, 2#000111#) But this only makes sense, if the bits are in complete reverse order: 7 58 1 000111 111010 000001 Therefore I assume that when overlaying the array of 6-bit elements over an array of 8-bit elements, I have to specify some kind of bit ordering, which however is not possible with 'Bit_Order. What am I missing here? --=20 Stefan Bellon