How windows handles \r and \n characters in XXXprintf() functions. The following program simulates what done when UL writes to a log file. - First LogTagSet::vwrite writes the output to a buffer using os::vsnprintf() - Then, LogFileStreamOutput::write writes the buffer to a text file using fprintf() ---------------------------------------------------------------------- #define _CRT_SECURE_NO_WARNINGS 1 // Build as a console app with Visual Studio 2019 #include void dump(const char* what, const char* s) { printf("const char %s[] = {", what); while (*s) { printf("0x%02x, ", *s); s++; } printf("}\n"); } int main() { char buffer[100]; char s[] = { 'a', '\r', '\n', 'b', 0 }; dump("s", s); snprintf(buffer, 100, "aa\n%s\nbb", s); dump("buffer", buffer); FILE* f = fopen("c:\\temp\\foo.txt", "w+"); fprintf(f, "%s", buffer); fclose(f); } ---------------------------------------------------------------------- $ ./test.exe const char s[] = {0x61, 0x0d, 0x0a, 0x62, } const char buffer[] = {0x61, 0x61, 0x0a, 0x61, 0x0d, 0x0a, 0x62, 0x0a, 0x62, 0x62, } $ hexdump -ve '1/1 "0x%.2x, "' foo.txt 0x61, 0x61, 0x0d, 0x0a, 0x61, 0x0d, 0x0d, 0x0a, 0x62, 0x0d, 0x0a, 0x62, 0x62, opc@hotspot-windows /cygdrive/c/temp ---------------------------------------------------------------------- Observation: [1] sprintf() does not perform \n -> \r\n conversion. The characters substituted for the %s are exactly the same chars as in s[]. const char buffer[] = {0x61, 0x61, 0x0a, 0x61, 0x0d, 0x0a, 0x62, 0x0a, 0x62, 0x62, } <- %s -> [2] fprintf performs \n -> \r\n conversion (if it configured to write into a text file). See the bytes marked by vvvvvv vvvvvvvvvv vvvvvvvvvv vvvvvvvvvv 0x61, 0x61, 0x0a, 0x61, 0x0d, 0x0a, 0x62, 0x0a, 0x62, 0x62 <- input to fprintf 0x61, 0x61, 0x0d, 0x0a, 0x61, 0x0d, 0x0d, 0x0a, 0x62, 0x0d, 0x0a, 0x62, 0x62, <- output written by fprintf into foo.txt ^^^^^^^^^^^^^^^^ Note that fprintf does NOT process the \r characters. It leaves them alone. See the bytes marked by ^^^^^^^^ E.g., the input bytes \r\n becomes \r\r\n in foo.txt Conclusion: Windows C library performs newline translation only on the \n characters. Since our proposal will transform all \n characters to {0x5c, 0x6e}, the Windows C library will write the data as is into the output file, without any further translation.