A fixed-length binary code is called t-unidirectional error detecting if no codeword can be transformed into another codeword by at most t unidirectional errors. In this paper we consider the problem of mapping information sequences of length k into codewords of a t-unidirectional error detecting code of length k + p. In case of systematic codes we show that the parameters p and t must satisfy the relation t less-than-or-equal-to 2p - 2p/2+1 + p. Moreover, we give a simple systematic encoding to map information sequences into codewords of a t-unidirectional error detecting code. In case of non-systematic codes, we give a method to design t-unidirectional error detecting codes in which the number p of check bits must satisfy the inequality t less-than-or-equal-to 2p - p - 1. The encoding and decoding algorithms require time linear in the number k of information bits.