In support/thunk/kernel32/u/WriteFile.cc, the console code path converts the input buffer using:
|
if (!w_buffer.from_a(static_cast<const char *>(lpBuffer), |
|
nNumberOfBytesToWrite)) { |
which decodes the input using CP_ACP.
However, when handling a partial write, the code converts the wide string back using:
|
if (!u_written.from_w(w_buffer.c_str())) { |
and u_str::from_w() encodes using UTF-8.
This appears inconsistent: the input buffer is decoded using ACP (from_a()), while the byte count is calculated using UTF-8 (u_str::from_w()).
Additionally, in the partial-write path:
|
d::u_str u_written; |
|
if (!u_written.from_w(w_buffer.c_str())) { |
|
SetLastError(ERROR_OUTOFMEMORY); |
|
return FALSE; |
|
} |
|
*lpNumberOfBytesWritten = u_written.size(); |
converts the entire buffer instead of only the first w_written characters reported by WriteConsoleW(), so lpNumberOfBytesWritten may not reflect the actual number of bytes written.
In
support/thunk/kernel32/u/WriteFile.cc, the console code path converts the input buffer using:mingw-lite/support/thunk/kernel32/u/WriteFile.cc
Lines 34 to 35 in 1e051ec
which decodes the input using CP_ACP.
However, when handling a partial write, the code converts the wide string back using:
mingw-lite/support/thunk/kernel32/u/WriteFile.cc
Line 49 in 1e051ec
and
u_str::from_w()encodes using UTF-8.This appears inconsistent: the input buffer is decoded using ACP (
from_a()), while the byte count is calculated using UTF-8 (u_str::from_w()).Additionally, in the partial-write path:
mingw-lite/support/thunk/kernel32/u/WriteFile.cc
Lines 48 to 53 in 1e051ec
converts the entire buffer instead of only the first
w_writtencharacters reported byWriteConsoleW(), solpNumberOfBytesWrittenmay not reflect the actual number of bytes written.