build: remove the 11 UTF-8 BOMs, and stop editors re-adding them (#1499)

Every BOM in the tree, and an .editorconfig so Visual Studio does not put
them back.

All eleven carry no information: none of the files contains a single
non-ASCII byte, so the BOM was the only non-ASCII content in each.
Visual Studio wrote them when it generated or last touched those project
files.  Ten are .vcxproj.filters; two are the sqlproxy and sqlslave
.vcxproj, which is why the /utf-8 commit had to restore them mid-change.

The concern that makes this worth more than tidying: Visual Studio adds a
signature when it needs to represent a non-ASCII character in a file that
had none.  These files are pure ASCII, so removing the BOM should stick --
VS preserves the encoding it finds.  But #1499 step 2 converts source
prose from \xE2\x80\x99 escapes to characters, which is precisely the
condition that starts making VS write signatures, and on .cpp rather than
on project files.

.editorconfig is the lever for that.  charset = utf-8 means UTF-8 WITHOUT
a BOM (utf-8-bom is the spelling for with), and Visual Studio honours it,
as do VS Code, CLion and Sublime.  It is deliberately the only key set:
indentation, line endings and trailing whitespace are left to existing
practice and CLAUDE.md, so the file cannot reformat anything by surprise.

Git cannot do this job, which is worth recording because it is the
obvious place to look.  core.autocrlf is line endings only, and
.gitattributes' working-tree-encoding converts encodings rather than
stripping a signature -- pointing it at UTF-16 would ADD one.  Stripping
a BOM through git needs a custom clean filter that every clone has to
configure locally; an .editorconfig needs no setup and acts where the BOM
is actually introduced.

A BOM is harmless to MSVC and tolerated by gcc and clang, so this is not
a correctness fix for compiled sources.  It matters for files that are
executed rather than compiled -- a shell script or a .mux corpus file
with a BOM simply does not work -- and for keeping diffs free of churn
that depends on who last opened a file in an IDE.

Verified: full rebuild of all eleven projects clean, including the two
whose .vcxproj lost its BOM; smoke 316 dispatched, 1487 succeeded, 17
failed (the known build-configuration failures here); format, netaddr and
alarm harnesses pass; zero BOMs left in any tracked file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Stephen Dennis 2026-07-26 21:20:02 -06:00
parent ee66b0083a
commit a70362ef63
12 changed files with 46 additions and 11 deletions

35
.editorconfig Normal file
View file

@ -0,0 +1,35 @@
# EditorConfig — https://editorconfig.org
#
# Deliberately minimal. This file exists for ONE reason: to stop editors
# writing a UTF-8 BOM.
#
# Visual Studio saves a file as "UTF-8 with signature" when it needs to
# represent a non-ASCII character and the file had none before. That is
# harmless for MSVC, which accepts a BOM, but it is invisible churn in
# diffs, it varies by who last opened the file, and a BOM is fatal to any
# file that is executed rather than compiled -- a shell script or a .mux
# corpus file with a BOM does not work.
#
# The risk is about to grow: #1499 adds /utf-8 so source prose can be
# written as characters instead of \xE2\x80\x99 escapes, which is exactly
# the condition that makes Visual Studio start adding signatures.
#
# `charset = utf-8` means UTF-8 WITHOUT a BOM; `utf-8-bom` is the spelling
# for with. Visual Studio honours this, as do VS Code, CLion, Sublime and
# most others.
#
# Note for anyone reaching for git instead: git cannot do this.
# core.autocrlf is line endings only, and .gitattributes'
# working-tree-encoding converts encodings rather than stripping a
# signature -- setting it to UTF-16 would ADD one. Stripping a BOM in git
# needs a custom clean filter, which every clone has to configure locally.
# An .editorconfig needs no setup and fixes it at the point it happens.
#
# Nothing else is set here on purpose. Indentation, line endings and
# trailing whitespace are left to existing practice and to the code-style
# rules in CLAUDE.md, so this file cannot reformat anything by surprise.
root = true
[*]
charset = utf-8

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="lapi.c">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="comsys_mod.h">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="ast.cpp">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="..\..\include\config.h">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="..\..\include\config.h">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">