def toBytes(text):
    """Convert string (unicode) to bytes."""
    try:
        if type(text) != bytes:
            text = bytes(text, 'UTF-8')
    except TypeError:
        text = "\n[WARNING] : Failed to encode unicode!\n"
    return text