code: def _try_char(character, backup, encoding=sys.stdout.encoding):
      
      if character.encode(encoding, 'replace') == b'?':
          return backup
      else:
          return character
docs: Return `character` if it can be encoded using sys.stdout, else return the
      backup character.