An encoder may have a compressed mode in which a stream of input
characters may be encoded into code words. The encoder may have a
transparent mode in which the output stream is substantially identical to
the input stream. The encoder may switch from one mode to the other based
at least in part upon a data compressibility test. The test may comprise
comparing an N-segment sliding average of the number of bits required by
the encoder in compressed mode to represent a segment of a fixed number
of characters to the number of bits required by the encoder in
transparent mode to represent the segment.