code: def _encode_char(char, charmap, defaultchar):
          
          if ord(char) < 128:
              return ord(char)
          if char in charmap:
              return charmap[char]
          return ord(defaultchar)
docs: Encode a single character with the given encoding map
  
          :param char: char to encode
          :param charmap: dictionary for mapping characters in this code page