Modulation constraints of practically any degree of complexity can be described by a state transition table with a finite number approximately $OMEGA of states. Examples include all (d,k;c) codes (where approximately $OMEGA ≤ 2(k + 1)(2c + 1), more general codes with run-length limitations, and run-length limited codes which exclude certain bit-patterns. From the state transition table we construct a trellis diagram for code words of arbitrary length L0. If desired, the trellis may be confined in the beginning and/or at the end to a subset of states. We then show a simple method of enumeration that assigns a number to each code word in the trellis according to its lexicographic order. All the necessary information for enumerative encoding and decoding of binary data will be subsequently stored in an array of size L0 × approximately $OMEGA; both encoding and decoding can be achieved with a few simple operations using this table. In short, arbitrarily long blocks of data can be encoded into sequences that satisfy arbitrary constraints, with algorithms that are easy to implement. Since no additional constraints are imposed, the rates approach Shannon's noiseless channel capacity in the limit of long sequences. Ideas are presented for correction of random errors that occur in modulated sequences, so that errors in readout can be corrected prior to demodulation. These post- modulation error correction codes are necessary when modulation can be corrected prior to demodulation. These post-modulation error correction codes are necessary when modulation code words are long, in which case small errors can destroy large quantities of data. Also introduced in this paper is a simple, efficient algorithm for burst-error-correction. The primary application of the ideas of this paper is in the area of data encoding/decoding as applied in magnetic and optical data storage systems.