def METHOD_NAME(text: Any, encoding: str = DEFAULT_ENCODING) -> Optional[str]:
    text = stringify(text, encoding_default=encoding)
    if text is None:
        return None
    try:
        text = compose_nfc(text)
    except (SystemError, Exception) as ex:
        log.warning("Cannot NFC text: %s", ex)
        return None
    text = remove_unsafe_chars(text)
    if text is None:
        return None
    byte_text = text.encode(DEFAULT_ENCODING, "replace")
    return cast(str, byte_text.decode(DEFAULT_ENCODING, "replace"))