open in text mode (O_TEXT) (Developers)
Hello kerravon,
Actually, O_TEXT and O_BINARY seem more and more like a rather inelegant (if practical) hack to me these days. I now think the Newlib library has the right idea: have read (...) and write (...) always return raw binary data, and convert between LF and CRLF at one and only one layer: at the stdio level (fopen, fread, fwrite, printf, scanf, etc.).
I think the only reason O_TEXT and O_BINARY exist is that some programs use read and write, and assume that the data handled by these routines contain Unix-style newlines. The more correct way to get these programs to work on DOS, is probably to rewrite these programs to read/write text files via stdio, but I realize this may not always be practical.
Meanwhile, int 0x21, ah = 0x3f or 0x40 have always dealt with raw bytes, and continue to do so.
So... I would advise against modifying the raw system calls (i.e. int 0x21, ah = 0x3f or 0x40) to do any sort of encoding conversion. Having LF ↔ CRLF conversion potentially happening at any and all of the 3 interface layers (machine syscall, POSIX routine, stdio) sounds like a recipe for chaos. But you do you.
Thank you!
---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"
Complete thread:
- open in text mode (O_TEXT) - kerravon, 24.02.2025, 04:19
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- open in text mode (O_TEXT) - kerravon, 24.02.2025, 04:24
- open in text mode (O_TEXT) - tkchia, 26.02.2025, 16:30
- open in text mode (O_TEXT) - Rugxulo, 27.02.2025, 00:29
- open in text mode (O_TEXT) - kerravon, 02.03.2025, 01:30
- open in text mode (O_TEXT) - kerravon, 02.03.2025, 01:33
- open in text mode (O_TEXT) - tkchia, 03.03.2025, 15:09
- open in text mode (O_TEXT) - kerravon, 02.03.2025, 01:35
- open in text mode (O_TEXT) - tkchia, 26.02.2025, 16:30
- open in text mode (O_TEXT) - kerravon, 24.02.2025, 04:24
Mix view