def encode(self, text, encoding, defaultchar='<STR_LIT:?>'):
codepage_char_map = self._get_codepage_char_map(encoding)<EOL>output_bytes = bytes([self._encode_char(char, codepage_char_map, defaultchar) for char in text])<EOL>return output_bytes<EOL>
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