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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7844279822ce7c28 X-Google-Attributes: gid103376,public From: Wilhelm Spickermann Subject: RE: Newbie question : types , representation Date: 1999/08/22 Message-ID: #1/1 X-Deja-AN: 515809953 Content-Transfer-Encoding: 8bit Sender: wilhelm@pc1.spick.nowhdus References: <37BFC251.601ADF8F@village.uunet.be> X-Sender: 0211750756-0001@t-online.de X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@t-online.de X-Trace: news04.btx.dtag.de 935333159 4156 0211750756-0001 990822 14:45:59 Organization: T-Online Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-08-22T00:00:00+00:00 List-Id: On 22-Aug-99 Jos De Laender wrote: > ... > In base64 decoding , each ASCII character must be translated to 6 > 'bit'. > 4 characters translate then to 3 bytes. The problem and algorithms > ... I think there are two different problems: - converting 8 bit characters to 6 Bit somethings - packing over the byte borders That 6-bit-something is: type Char_64 is mod 2**6; for Char_64'Size use 6; The Conversion may be done using a simple Table: type Conversion_Table_Type is array (Character) of Char_64; Conversion_Table: constant Conversion_Table_Type := {0,1,2,3,...}; The second problem may be solveable using the following parts (look into Cohen: Ada as a second language, 2nd Ed.; Part 19.4.5 where he solved the problem of working with Microsofts FAT12 (12 Bit numbers in a packed array)) type Char_64_Array is array (Sometype) of Char_64; type Packed_Char_64_Array is new Char_64_Array; for Packed_Char_64_Array'Component_Size use 6; pragma Pack (Packed_Char_64_Array); Now we can use both types - the packed and the unpacked one - in the normal way. But access to the unpacked one is much more efficient and conversion is easy: Packed_One: Packed_Char_64_Array; Unpacked_One: Char_64_Array; ... -- now we can fill the unpacked array efficiently ... -- and now we pack them: Packed_One := Packed_Char_64_Array(Unpacked_One); Wilhelm