private static void decodeAnsiX12Segment(BitSource bits,StringBuilder result) throws FormatException {
  int[] cValues=new int[3];
  do {
    if (bits.available() == 8) {
      return;
    }
    int firstByte=bits.readBits(8);
    if (firstByte == 254) {
      return;
    }
    parseTwoBytes(firstByte,bits.readBits(8),cValues);
    for (int i=0; i < 3; i++) {
      int cValue=cValues[i];
      if (cValue == 0) {
        result.append('\r');
      }
 else       if (cValue == 1) {
        result.append('*');
      }
 else       if (cValue == 2) {
        result.append('>');
      }
 else       if (cValue == 3) {
        result.append(' ');
      }
 else       if (cValue < 14) {
        result.append((char)(cValue + 44));
      }
 else       if (cValue < 40) {
        result.append((char)(cValue + 51));
      }
 else {
        throw FormatException.getFormatInstance();
      }
    }
  }
 while (bits.available() > 0);
}

private static void decodeAnsiX12Segment ( BitSource bits , StringBuilder result ) throws FormatException { int [ ] cValues = new int [ 3 ] ; do { if ( bits . available ( ) == 8 ) { return ; } int firstByte = bits . readBits ( 8 ) ; if ( firstByte == 254 ) { return ; } parseTwoBytes ( firstByte , bits . readBits ( 8 ) , cValues ) ; for ( int i = 0 ; i < 3 ; i ++ ) { int cValue = cValues [ i ] ; if ( cValue == 0 ) { result . append ( '\r' ) ; } else if ( cValue == 1 ) { result . append ( '*' ) ; } else if ( cValue == 2 ) { result . append ( '>' ) ; } else if ( cValue == 3 ) { result . append ( ' ' ) ; } else if ( cValue < 14 ) { result . append ( ( char ) ( cValue + 44 ) ) ; } else if ( cValue < 40 ) { result . append ( ( char ) ( cValue + 51 ) ) ; } else { throw FormatException . getFormatInstance ( ) ; } } } while ( bits . available ( ) > 0 ) ; }
see iso 16022 : 2006 , 5 . 2 . 7
