[3.12] gh-52551: Fix encoding issues in strftime() (GH-125193) (GH-125657) (GH-125661)
Fix time.strftime(), the strftime() method and formatting of the
datetime classes datetime, date and time.
* Characters not encodable in the current locale are now acceptable in
the format string.
* Surrogate pairs and sequence of surrogatescape-encoded bytes are no
longer recombinated.
* Embedded null character no longer terminates the format string.
This fixes also gh-78662 and gh-124531.
(cherry picked from commit
08ccbb9b3f5e20a7a0c4cf9995e172b59fb6067b)
(cherry picked from commit
ad3eac1963a5f195ef9b2c1dbb5e44fa3cce4c72)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>