Ioannis Vranos wrote in news:1110072229.85604 @athnrd02: > Jim Rogers wrote: > >>>C:\c>temp >>>character: ⁿ >>>character: = >>>character: > >>>character: >>> >>>252 61 62 0 >>> >>>00111111 >>>10111100 >>>01111100 >>>00000000 >>> >>>C:\c> >>> >> >> All this can be done in Ada. > > > It would be great if we saw the code and its output. > Ok. That is certainly a fair requirement. with Ada.Text_Io; with Ada.Integer_Text_Io; with System; procedure String_Bits is S : String := "This is a text message"; L : Natural := S'Size; type Bits_Array is array (1..L) of Boolean; pragma Pack (Bits_Array); Bits : Bits_Array; for Bits'Address use S'Address; begin -- Display the bits of each character for I in Bits'range loop Ada.Integer_Text_Io.Put(Item => Boolean'Pos(Bits(I)), Width => 1); if I mod System.Storage_Unit = 0 then Ada.Text_Io.New_Line; end if; end loop; end String_Bits; The output is: 00101010 00010110 10010110 11001110 00000100 10010110 11001110 00000100 10000110 00000100 00101110 10100110 00011110 00101110 00000100 10110110 10100110 11001110 11001110 10000110 11100110 10100110 The program declares a string S initialized to "This is a text message". It then declares an array type named Bits_Array. That array type is an array of Boolean, with the number of elements equal to the number of bits in used by S. The variable L is set to equal the value returned by the Size attribute of the String S. Ada reports size as the number of bits, not the number of bytes. A packed array of boolean allocates one storage element to each bit. Therefore, the statement pragma Pack(Bits_Array); causes all instances of Bits_Array to be a packed array. The variable Bits is declared to be of the type Bits_Array. The next statement forces Bits to overlay S. Both variables are the same size and start at the same address. The body of the procedure simply iterates through all the bits in the Bits variable and prints the numeric value of each bit. A new line is output whenever the loop control variable mod System.Storage_Unit evaluates to 0. System.Storage_Unit is provided by Ada so that the program will properly represent each storage unit (sometimes called a byte) no matter what the size of that unit is. As you can clearly see, Ada can represent the bits of a variable with very little difficulty. Ada does not store a null at the end of a string. This is why there is no indication of a null value for the last byte. Jim Rogers