src: fix console debug output on Windows
The FWrite function on Windows assumed that MultiByteToWideChar
automatically null-terminates the resulting string, but it will only do
so if the size of the source was passed as -1 or null character was
explicitly counted in the size. The FWrite uses std::string and its
.size()
method which doesn't count the null character even though the
.data()
method adds it to the resulting string.
MultiByteToWideChar does not null-terminate an output string if the input string length is explicitly specified without a terminating null character. To null-terminate an output string for this function, the application should pass in -1 or explicitly count the terminating null character for the input string.
Discovered while debugging http2 tests on windows, all native logs were in one line. Hopefully I didn't miss another thing in the MultiByteToWideChar doc, it's quite confusing.
/cc @addaleax
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines