import json
import struct


def encode_message(message_content: str):
    """
    Encode a message for transmission, given its content.
    :param message_content: a message
    """
    encoded_content = json.dumps(message_content).encode("utf-8")
    encoded_length = struct.pack('=I', len(encoded_content))
    # use struct.pack("10s", bytes)
    # to pack a string of the length of 10 characters

    return {'length': encoded_length,
            'content': struct.pack(str(len(encoded_content))+"s",
                                   encoded_content)}