Stdio: a note about redirection in Windows
Windows stdio redirection works in A93, but there are some things to know:
In R3 the redirected stdin and stdout streams are UTF-8 encoded.
In R3 the default console window is Unicode wide-char encoded.
Do not mix the two modes.
For example, from a Command Prompt window, you can redirect output, or input and output:
> r3 -q test.r >output.txt
> r3 -q test.r <input.txt >output.txt
But, if you only redirect input:
> r3 -q test.r <input.txt
you're going to see a window pop up to handle any output. I've not found any way to solve this problem in Windows, nor do I find any information about it on the web. So, my advice is to redirect output as well.
Why?
The problem here comes from the fact that when running from a Command Prompt window, the handle returned by:
GetStdHandle(STD_OUTPUT_HANDLE)
is not valid for WriteFile() . Why? I cannot say. I researched it, but found no good explanation.
Of course, it's problematic anyway because you can't write UTF-8 to just any device in Windows. Windows is based on wide-char Unicode.
However, if you find the solution to this problem, let me know.
11 Comments