Set codepage to console cp for pipes vs. system cp for redirected files.
Free Unicode buffer in 3 more cases.
Determine size of Unicode buffer via MultiByteToWideChar(), NUL terminate.
Input buffer handling: Fix reallocation after end of input.