from datetime import datetime
import warnings


def _std_strftime(dt_obj: datetime, fmt_char: str) -> str:
    """
    Standard datetime.strftime() with normalization and exception handling.
    """
    str_ = ""
    try:
        str_ = dt_obj.strftime(f"%{fmt_char}")
        if not str_ or str_ == f"%{fmt_char}":
            # normalize outputs for unsupported directives
            # in different platforms
            # "%Q" may result "%Q", "Q", or "", make it "Q"
            str_ = fmt_char
    except ValueError as err:  # pragma: no cover
        # Unsupported directives may raise ValueError on Windows,
        # in that case just use the fmt_char
        warnings.warn(
            (f"String format directive unknown/not support: %{fmt_char}" f"The system raises this ValueError: {err}"),
            UserWarning,
        )
        str_ = fmt_char
    return str_