Jump to content
Excelsior Forums

Output of Unix-like EOL (single LF character) in Windows

Recommended Posts

I wanted to create a console tool to process some text files. I took XDS Oberon, for it's the simplest console implementation of Oberon to date. It was required that some of the output files would contain Unix-like end-of-line markers (the single LF character = 0AX).

I tried Out.Ln, it outputs CRLF, which is normal in Windows. There is no setting to change that AFAIK, but that's OK.

Out.Char(0AX) also outputs CRLF. This is a bit weird.

Alright, the Out module is a just wrapper for the standard IO channels subsystem, which is written in Modula. Let's dive into that subsystem.

RawIO.Write(StdChans.OutChan(), 0AX); - outputs CRLF.

ch := 0AX; IOChan.RawWrite(StdChans.OutChan(), SYSTEM.ADR(ch), 1); - outputs CRLF.

I feel like an idiot.

Is there a way to push a single 0AX character through a channel without getting the CR in front of it?

Share this post

Link to post
Share on other sites

No, you are not an idiot. See my post `IOChan.RawWrite cooks' (20 September 2005 - 11:31 PM) although it is about XDS Modula-2. And, if you like to hear, IOChan.RawRead has the same problem, i.e. you get CR/LF when the file has only LF.

My anser: Import Windows module and write RawWrite yourself.

PROCEDURE RawWrite(cid: ChanId; from: ADDRESS; locsToWrite: CARDINAL);




IF Windows.WriteFile(cid^.Handle, from, locsToWrite, res, NIL) THEN



(*put error message if you like*)

HALT() END END RawWrite;

But this means that you rewrite all other file i/o procedures including open and close, as well as the entire InOut module. I did it.

I hope the new version be better, but I think I will keep using my own library for the sake of compatibility and simplicity.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now