def to_env(text):
    # type: (Text) -> str
    """
    Encode a string the same way whether it comes from the environment or a `.env` file.
    """
    if PY2:
        return text.encode(sys.getfilesystemencoding() or "utf-8")
    else:
        return text

    Encode a string the same way whether it comes from the environment or a `.env` file.
    
dynaconf/vendor/dotenv/compat.py