Stripping utf8-bom before formatting files - #576
Closed
KaranPradhan266 wants to merge 2 commits into
Closed
Conversation
hick209
approved these changes
Dec 17, 2025
Collaborator
|
Overall it LGTM. |
Contributor
Author
|
@hick209 done!, Thanks for reviewing it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #565
Strip UTF-8 BOM before formatting
Problem
Some Kotlin source files may begin with a UTF-8 Byte Order Mark (BOM,
\uFEFF).When such a file is passed to the formatter, the BOM is treated as part of the source text rather than metadata. This leads to an error while parsing.
Although BOMs are unnecessary for UTF-8 and discouraged for Kotlin source files, they can still appear due to editor defaults or generated files.
Solution
This change strips a leading UTF-8 BOM (
\uFEFF) from file contents before formatting. By removing the BOM at input time:This aligns with Kotlin tooling expectations and prevents BOM-related formatting errors without affecting valid source code.
Notes