News for hackers. Stuff that matters.
Re:What's new in the .NET 11 runtime by kbolino on Tuesday November 10, 2026 @12:15PM (#50443261)
There's one (usually minor) caveat here, which is around strings. In .NET, like Windows*, strings are UTF-16. If you call into native code that uses UTF-8 strings extensively, then they have to be marshalled (when passed to native code) and unmarshalled (when received from native code), which takes additional time and memory. I've run into this lately, which has led me to write special CStr/CString types (idea borrowed from Rust) to avoid unnecessary, especially round-trip, (un-)marshalling.

* = Technically, Windows now supports the UTF-8 "code page" where applications can use UTF-8 natively, but all NT system calls use UTF-16, so the conversion still has to happen somewhere

Re:What's new in the .NET 11 runtime by WorldMaker on Tuesday November 10, 2026 @01:01PM (#50443813)
C# in .NET 11 adds support for UTF-8 string literals (`ReadOnlySpan<byte> str = "Some sample string."u8;`) which is a step to making such interop easier.

The Runtime has explored attempting "UTF-8 native" string storage as a platform feature especially for Linux FFI, but yeah Windows using UTF-16 is still a compatibility issue where platforms themselves just don't agree.