frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

How do I inform Windows that I'm writing a binary file?

https://devblogs.microsoft.com/oldnewthing/20260504-00/?p=112296
15•ingve•1d ago

Comments

saltyoldman•1d ago
fopen(..., "wb") ?
qbane•1h ago
It's C library taking care of the "b" part for you according to the article.
wahern•56m ago
It's the other way around. It's the C runtime that treats text ("t") mode differently, because the C standard specifies \n as a line delimiter but the Windows convention is \r\n. In text mode C stdio translates between \n and \r\n. In binary mode it does no translation.
lmm•1h ago
The article seems to be taking the position that the C runtime library is not part of "Windows", which feels like a rather odd view to me. What is the stable API that Windows offers to application developers if not that?
ChrisSD•59m ago
The Win32 API. E.g. using WriteFile to write files (https://learn.microsoft.com/en-us/windows/win32/api/fileapi/...)

It wasn't until fairly recently that the C runtime was stably shipped with Windows. Previously you had to install the correct version of the C library alongside your application.

lmm•48m ago
> The Win32 API. E.g. using WriteFile to write files (https://learn.microsoft.com/en-us/windows/win32/api/fileapi/...)

Which is called from what, if not C? Does windows really offer no API for writing text (rather than bytes) to files? Or does it rely on the application developer to manage line endings in their own code? Neither of those sounds very developer-friendly.

p_l•44m ago
The whole issue is specific to C and languages that copied C or use its runtime underneath in implementations (like Python)

For reference, Unix has no API other than bytes either.

ChrisSD•26m ago
Calling it from C does not mean you need a full C standard library to exist. For example, much of the C standard library is itself written in C. But it's a "freestanding" C which assumes only a minimal set of library functions exist (e.g. functions for copying memory from one place to another, filling memory with zeroes, etc).

And you can of course use non-C languages to call the Win32 API. Or even directly using assembly code.

lmm•2m ago
> you can of course use non-C languages to call the Win32 API. Or even directly using assembly code.

Is that a supported/official API though? On Linux you "can" put your arguments in registers and trigger the system call interrupt directly, and I think Go programs even do this, but it's not the official interface and they reserve the right to break your program in future updates, at least in theory.

p_l•50m ago
Indeed, C runtime is not part of windows API, and it's normal to have a program include few different copies of C runtime library due to different modules compiled with different compilers/options.

C runtime library being part of OS is accidental thing in Unix, 16bit and 32bit Windows API even does not use C-compatible ABI (instead, Pascal-compatible one is present)

Isamu•50m ago
Going all the way back to the earliest C compilers. There was a decision made to make “\n” just work on DOS for portability of Unix programs, and to make the examples from the C programming book just work.

But in Unix “\n” is a single byte, and in DOS it is 2. So they introduced text and binary modes for files on DOS. Behind the scenes the library will handle the extra byte. This is not necessary in Unix.

I used to have to be careful about importing files to DOS. Did the file come from Unix?

criddell•43m ago
Linefeed (\n) is a single byte in DOS as well.

I think you are talking about carriage return linefeed pair (CRLF or \r\n),

These control codes go back to line printers. Linefeed advances the paper one line and carriage return moves the print head to the left.

Valve releases Steam Controller CAD files under Creative Commons license

https://www.digitalfoundry.net/news/2026/05/valve-releases-steam-controller-cad-files-under-creat...
1063•haunter•10h ago•348 comments

The Vatican's Website in Latin

https://www.vatican.va/latin/latin_index.html
22•ks2048•32m ago•7 comments

Appearing productive in the workplace

https://nooneshappy.com/article/appearing-productive-in-the-workplace/
719•diebillionaires•9h ago•281 comments

How I made $350K from an open-source JavaScript library using dual licensing

https://www.paritydeals.com/blog/monetize-open-source-dual-licensing/
34•sachinneravath•1h ago•8 comments

The Old Guard: Confronting America's Gerontocratic Crisis

https://harpers.org/archive/2026/05/the-old-guard-samuel-moyn-gerontocracy/
24•Caiero•1h ago•11 comments

Vibe coding and agentic engineering are getting closer than I'd like

https://simonwillison.net/2026/May/6/vibe-coding-and-agentic-engineering/
397•e12e•10h ago•431 comments

From Supabase to Clerk to Better Auth

https://blog.val.town/better-auth
204•stevekrouse•8h ago•129 comments

The bottleneck was never the code

https://www.thetypicalset.com/blog/thoughts-on-coding-agents
510•Anon84•2d ago•330 comments

Google Cloud fraud defense, the next evolution of reCAPTCHA

https://cloud.google.com/blog/products/identity-security/introducing-google-cloud-fraud-defense-t...
211•unforgivenpasta•7h ago•202 comments

Building my own Vi text editor in BASIC

https://leetusman.com/nosebook/yvi
24•zeech•1d ago•8 comments

Show HN: Hallucinopedia

http://halupedia.com/
150•bstrama•9h ago•154 comments

Learning the Integral of a Diffusion Model

https://sander.ai/2026/05/06/flow-maps.html
92•benanne•7h ago•17 comments

Show HN: Tilde.run – Agent sandbox with a transactional, versioned filesystem

https://tilde.run/
127•ozkatz•10h ago•95 comments

Community firmware for the Xteink X4 e-paper reader

https://github.com/crosspoint-reader/crosspoint-reader
47•dmos62•1d ago•20 comments

Programming Still Sucks

https://www.stvn.sh/writing/programming-still-sucks-fqffhyp
91•jeromechoo•6h ago•17 comments

How do I inform Windows that I'm writing a binary file?

https://devblogs.microsoft.com/oldnewthing/20260504-00/?p=112296
15•ingve•1d ago•12 comments

A Theory of Deep Learning

https://elonlit.com/scrivings/a-theory-of-deep-learning/
124•elonlit•1d ago•28 comments

Inkscape 1.4.4

https://inkscape.org/doc/release_notes/1.4.4/Inkscape_1.4.4.html
216•s1291•6h ago•57 comments

Ted Turner has died

https://www.cnn.com/2026/05/06/us/ted-turner-death
225•pseudolus•11h ago•186 comments

Show HN: I built an open-source email builder, alternative to Beefree/Unlayer

https://play.templatical.com
99•oahmadov•9h ago•24 comments

Perturb-MARS: Reading mouse experiments through a human lens

https://www.noetik.blog/p/perturb-mars-reading-mouse-experiments
3•crescit_eundo•2d ago•0 comments

Show HN: PHP-fts – Full-text search engine in pure PHP, no extensions

https://github.com/olivier-ls/php-fts
31•asmodios•5h ago•7 comments

SQLite Is a Library of Congress Recommended Storage Format

https://sqlite.org/locrsf.html
12•whatisabcdefgh•3h ago•1 comments

Iran hit more U.S. military targets than has been reported, satellite images

https://www.washingtonpost.com/investigations/2026/05/06/iran-us-bases-satellite-images/
73•SanjayMehta•1h ago•38 comments

Higher usage limits for Claude and a compute deal with SpaceX

https://www.anthropic.com/news/higher-limits-spacex
386•meetpateltech•9h ago•332 comments

Setting up a Sun Ray server on OpenIndiana Hipster 2025.10

https://catstret.ch/202605/srss-hipster202510/
127•jandeboevrie•15h ago•46 comments

SoundOff: Low-Cost Passive Ultrasound Tags

https://yibo-fu.com/SoundOff-Low-cost-Passive-Ultrasound-Tags-for-Non-invasive-and-Non
33•jonbaer•8h ago•1 comments

What makes a good smartphone camera?

https://cadence.moe/blog/2026-05-05-what-makes-a-good-smartphone-camera
78•zdw•1d ago•55 comments

Virtual violin produces realistic sounds

https://news.mit.edu/2026/mit-engineers-virtual-violin-produces-realistic-sounds-0429
76•gmays•3d ago•61 comments

ADT says customer data stolen in cyber intrusion

https://therecord.media/ADT-data-breach-cyberattack
15•PaulHoule•2h ago•2 comments