-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS.Cmd \n -> \r\n conversions on Windows #65
Comments
Isn't the problem here that you are using I just checked and the |
In fact you are using I could use
What would Windows users expect ? I kind of think that these automatic translations are more harmful than beneficial so I'm tempted by 2. With 1. it basically means that non Windows user have to think about this and they will not. |
The source of this problem is I think the expectation would be that stdhandles are treated in the same way as files, certainly. I don't have a reasoned opinion on which way it should be, though, I'm afraid! There is already a disparity between how Unix.(write stdout "\n" 0 1) |> ignore;
Pervasives.(output stdout "\n" 0 1) |> ignore writes I expect that the rationale for this may be that the standard library behaves like the underlying C runtime (where You can detect whether a channel is in binary mode via an exposed runtime function, but you have to use a slightly unscrupulous, if entirely safe, C stub to get at it: #include <caml/memory.h>
CAMLextern int caml_channel_binary_mode (void *);
CAMLprim value caml_ml_channel_binary_mode(value vchannel)
{
CAMLparam1(vchannel);
CAMLreturn(Val_bool(caml_channel_binary_mode(*((void **) (Data_custom_val(vchannel))))));
} which can then be used with external get_binary_mode_in : in_channel -> bool = "caml_ml_binary_mode"
external get_binary_mode_out : out_channel -> bool = "caml_ml_binary_mode" It's a surprising omission from Pervasives... |
Under Windows, using the following programs the
\n
indata
is converted to\r\n
when the two programs are compiled and run asmain.exe test.exe
:Under something more Unix-y there is no issue, I'm guessing because there is no difference there between "text" and "binary" IO.
main.ml
test.ml
The text was updated successfully, but these errors were encountered: