From: Wilhelm Spickermann <wilhelm.spickermann@t-online.de>
Subject: RE: Newbie question : types , representation
Date: 1999/08/22
Date: 1999-08-22T00:00:00+00:00 [thread overview]
Message-ID: <XFMail.990822164551.wilhelm.spickermann@t-online.de> (raw)
In-Reply-To: 37BFC251.601ADF8F@village.uunet.be
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
next prev parent reply other threads:[~1999-08-22 0:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-22 0:00 Newbie question : types , representation Jos De Laender
1999-08-22 0:00 ` Wilhelm Spickermann [this message]
1999-08-23 0:00 ` Martin C. Carlisle
1999-08-23 0:00 ` Simon Wright
1999-08-22 0:00 ` Robert Dewar
1999-08-23 0:00 ` Wolfgang Jeltsch
1999-08-24 0:00 ` tmoran
1999-08-24 0:00 ` jdla
1999-08-24 0:00 ` Matthew Heaney
1999-08-24 0:00 ` Jos De Laender
1999-08-24 0:00 ` Brian Rogoff
1999-08-25 0:00 ` Jos De Laender
1999-08-22 0:00 ` Martin Dowie
[not found] ` <37C621F3.C6C0DC3A@acenet.com.au>
1999-08-27 0:00 ` David C. Hoos, Sr.
1999-08-27 0:00 ` tmoran
1999-08-27 0:00 ` Florian Weimer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox