SIGN IN SIGN UP

[3.13] gh-124008: Fix calculation of the number of written bytes for the Windows console (GH-124059) (GH-127325)

Since MultiByteToWideChar()/WideCharToMultiByte() is not reversible if
the data contains invalid UTF-8 sequences, use binary search to
calculate the number of written bytes from the number of written
characters.

Also fix writing incomplete UTF-8 sequences.

Also fix handling of memory allocation failures.
(cherry picked from commit 3cf83d91a5baf3600dd60f7aaaf4fb6d73c4b8a9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
M
Miss Islington (bot) committed
d2d1055129df2184e11947c25380da041959c347
Parent: 089d706
Committed by GitHub <noreply@github.com> on 11/30/2024, 9:16:45 AM