-
-
Notifications
You must be signed in to change notification settings - Fork 422
fix(builder): strip UTF-8 BOM from .ino sources before preprocessing #2983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When a sketch .ino is saved as UTF-8 *with BOM*, the BOM bytes (EF BB BF) reach the compiler and cause: stray '357円' in program stray '273円' in program stray '277円' in program This strips the BOM at read-time so the merged .cpp and copied sources are clean. Refs: arduino/arduino-ide#2752
CLA assistant check
All committers have signed the CLA.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## master #2983 +/- ## ======================================= Coverage 68.35% 68.36% ======================================= Files 241 241 Lines 22724 22731 +7 ======================================= + Hits 15534 15541 +7 Misses 5992 5992 Partials 1198 1198
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hi @per1234
I’ve added unit tests for the new stripUTF8BOM
function, and all checks are passing.
This PR should now be ready for review. Could you please take a look? Thanks!
Uh oh!
There was an error while loading. Please reload this page.
Arduino CLI: Strip UTF‐8 BOM from .ino before preprocessing
Summary
When a sketch
.ino
is saved as UTF-8 with BOM, the three BOM bytes (EF BB BF
) reach the compiler and cause:This PR strips the BOM at read-time so the merged
.cpp
and any copied sources are clean.Refs: #3015
Please check if the PR fulfills these requirements
See how to contribute
UPGRADING.md
has been updated with a migration guide (for breaking changes)configuration.schema.json
updated if new parameters are added.What kind of change does this PR introduce?
Bug fix — make the CLI robust to UTF-8 BOM at the start of
.ino
and additional files.What is the current behavior?
.ino
is saved as UTF-8 with BOM, the BOM bytes are preserved into the merged.cpp
, leading to compiler errors (stray '357円' / '273円' / '277円'
).What is the new behavior?
.ino
files.Implementation notes
internal/arduino/builder/sketch.go
→sketchMergeSources()
(viagetSource(...)
)internal/arduino/builder/sketch.go
→sketchCopyAdditionalFiles(...)
Test plan (manual)
Before this patch: fails with:
After this patch: succeeds.
Control: Save as UTF-8 (no BOM) → succeeds (unchanged).
Does this PR introduce a breaking change?
No. The change only strips a BOM if present; no impact on existing UTF-8 (no BOM) files or other encodings.
Other information