protected void encodeAtom(OutputStream outStream,byte data[],int offset,int len) throws IOException {
  int i;
  int p1, p2;
  byte a, b;
  a=data[offset];
  if (len == 2) {
    b=data[offset + 1];
  }
 else {
    b=0;
  }
  crc.update(a);
  if (len == 2) {
    crc.update(b);
  }
  outStream.write(map_array[((a >>> 2) & 0x38) + ((b >>> 5) & 0x7)]);
  p1=0;
  p2=0;
  for (i=1; i < 256; i=i * 2) {
    if ((a & i) != 0) {
      p1++;
    }
    if ((b & i) != 0) {
      p2++;
    }
  }
  p1=(p1 & 1) * 32;
  p2=(p2 & 1) * 32;
  outStream.write(map_array[(a & 31) + p1]);
  outStream.write(map_array[(b & 31) + p2]);
  return;
}

protected void encodeAtom ( OutputStream outStream , byte data [ ] , int offset , int len ) throws IOException { int i ; int p1 , p2 ; byte a , b ; a = data [ offset ] ; if ( len == 2 ) { b = data [ offset + 1 ] ; } else { b = 0 ; } crc . update ( a ) ; if ( len == 2 ) { crc . update ( b ) ; } outStream . write ( map_array [ ( ( a > > > 2 ) & 0x38 ) + ( ( b > > > 5 ) & 0x7 ) ] ) ; p1 = 0 ; p2 = 0 ; for ( i = 1 ; i < 256 ; i = i * 2 ) { if ( ( a & i ) != 0 ) { p1 ++ ; } if ( ( b & i ) != 0 ) { p2 ++ ; } } p1 = ( p1 & 1 ) * 32 ; p2 = ( p2 & 1 ) * 32 ; outStream . write ( map_array [ ( a & 31 ) + p1 ] ) ; outStream . write ( map_array [ ( b & 31 ) + p2 ] ) ; return ; }
encodeatom - take two bytes and encode them into the correct three characters . if only one byte is to be encoded , the other must be zero . the padding byte is not included in the crc computation .
