@ VisibleForTesting static byte [ ] ascii8To6bitBin ( byte [ ] toDecBytes ) { byte [ ] convertedBytes = new byte [ toDecBytes . length ] ; int sum = 0 ; int _6bitBin = 0 ; for ( int i = 0 ; i < toDecBytes . length ; i ++ ) { sum = 0 ; _6bitBin = 0 ; if ( toDecBytes [ i ] < 48 ) { throw new AisParseException ( AisParseException . INVALID_CHARACTER + " " + ( char ) toDecBytes [ i ] ) ; } else { if ( toDecBytes [ i ] > 119 ) { throw new AisParseException ( AisParseException . INVALID_CHARACTER + " " + ( char ) toDecBytes [ i ] ) ; } else { if ( toDecBytes [ i ] > 87 ) { if ( toDecBytes [ i ] < 96 ) { throw new AisParseException ( AisParseException . INVALID_CHARACTER + " " + ( char ) toDecBytes [ i ] ) ; } else { sum = toDecBytes [ i ] + 40 ; } } else { sum = toDecBytes [ i ] + 40 ; } if ( sum != 0 ) { if ( sum > 128 ) { sum += 32 ; } else { sum += 40 ; } _6bitBin = sum & 0x3F ; convertedBytes [ i ] = ( byte ) _6bitBin ; } } } } return convertedBytes ; }
Returns conversion of ASCII - coded character to 6 - bit binary byte array .