I will have a look at the mingw-64 sources and maybe file an issue
Seems to be a runtime issue.
https://winlibs.com provides a gcc-13.2.0 build with msv C runtime, and a separate gcc-13.2.0 build with universal C runtime.
The one with UCRT provides the utf-8 support, the one with MSVCRT does not.
Strawberry Perl uses the MSVCRT one, and if you want to build perl-5.38.0 (or earlier) with the UCRT one, you'll need to patch the perl source.
But perl-5.39.2 builds straight out of the box with the UCRT one.
Hence my own personal build of perl-5.39.2 (built by gcc-13.2.0 UCRT) provides the desired behaviour.
It might be that the UCRT version of gcc-13.1.0 (and perhaps earlier) might also provide that utf-8 support. (I haven't tested.)
In any case, one can grab the UCRT gcc-13.2.0 and check that C programs are receiving that utf-8 support.
Cheers,
Rob