A method for encoding an N-valued input symbol wherein N is an integer which is larger than 2M-4 but not greater than 2M, M being a non-negative integer, which comprises the steps of:converting the input symbol to M bits of binary symbols; selecting M contexts each of which corresponds to one of said M bits of binary symbols among a multiplicity of contexts, each of the multiplicity of contexts re