<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encode(self, text, encoding, defaultchar='?'):
 """ Encode text under the given encoding :param text: Text to encode :param encoding: Encoding name to use (must be defined in capabilities) :param defaultchar: Fallback for non-encodable characters """

        codepage_char_map = self._get_codepage_char_map(encoding)
        output_bytes = bytes([self._encode_char(char, codepage_char_map, defaultchar) for char in text])
        return output_bytes