Win32 C library can support UTF-8 file names using a manifest

The C library on Windows, in 2026, doesn't support UTF-8 file names by default. Fortunately, you can now enable support using a manifest.

Even better, if you're using Zig's Clang wrapper for targeting Windows, you can just add the manifest to your build command line and the manifest will get embedded in the executable, as desired. For example, here's a commit that enables this support for a Zig-built C tool, luasmith.

As annoying as this is, there are historical and back-compat reasons for this inconvenience on Windows, namely Windows predates Unicode. Unfortunately, Microsoft also "bet on the wrong horse" when they decided to move to UCS-2 (two-byte) encoding of characters. This was supposed to avoid cumbersome variable-length encodings, but Unicode grew so huge that now 16 bits is insufficient to encode arbitrary characters. Rather than break compatibility of old apps, new apps get to opt into breaking changes, like using UTF-8 instead of ancient concepts like code pages.

Example manifest (luasmith.exe.manifest from the previously linked commit):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity type="win32" name="luasmith.exe" version="6.0.0.0"/>
  <application>
    <windowsSettings>
      <activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
    </windowsSettings>
  </application>
</assembly>