code: def get_charset(message, default="utf-8"):
      
      if message.get_content_charset():
          return message.get_content_charset()
      if message.get_charset():
          return message.get_charset()
      return default
docs: Get the message charset