This digital circuit does exact opposite of the function of a decoder. It converts the information from 2 n to n lines. The truth table is:

We can easily design the circuit diagram from this table. How ever if mistakenly we have ‘1’ at two of the inputs then we’ll have wrong answer from the circuit. But the encoders which come in the form of ICs are priority encoders. These encoders establish a priority to make sure that only highest input is encoded in case of two or more inputs. So if we have 1s at input line 2 and 5, then we’ll have output as 101 as encoder would accept highest input which is 5.