def encode_utf_8_text(text):
    """Encodes the text to utf-8 format

    Parameters
    ----------
    text : str
        Text to be encoded

    Returns
    -------
    str
        Encoded text
    """
    try:
        return codecs.encode(text, 'utf-8')
    except (TypeError, ValueError):
        return text
Encodes the text to utf-8 format

    Parameters
    ----------
    text : str
        Text to be encoded

    Returns
    -------
    str
        Encoded text
    
tests/_utils.py