Skip to content
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

Respect byte-order mark. #799

Merged
merged 4 commits into from
May 3, 2020
Merged

Respect byte-order mark. #799

merged 4 commits into from
May 3, 2020

Conversation

nojaf
Copy link
Contributor

@nojaf nojaf commented Apr 28, 2020

This worked on my machine on Windows.
I'm not really an expert when it comes to these things, all suggestions to improve are welcome.

@nojaf nojaf requested review from jindraivanek and Smaug123 April 28, 2020 18:07
Copy link
Contributor

@Smaug123 Smaug123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% certain that Fantomas should respect BOM, honestly. I lean towards "yes, it should respect BOM", because it seems nice to write out in the same encoding that we read in; but I could understand if Fantomas were opinionated about output format.

src/Fantomas.CoreGlobalTool.Tests/TestHelpers.fs Outdated Show resolved Hide resolved
src/Fantomas.CoreGlobalTool/Program.fs Show resolved Hide resolved
@nojaf
Copy link
Contributor Author

nojaf commented Apr 28, 2020

I think it is a good thing to respect the BOM, the case about formatting outside the IDE seems like a valid one to have this.

FSharpSpec says:

All input files are currently assumed to be encoded as UTF-8.

See https://fsharp.org/specs/language-spec/4.1/FSharpSpec-4.1-latest.pdf#page=25
So I'm not sure we should support UTF16 and UT32 as well.
Any thoughts on this @jindraivanek?

@auduchinok how does Rider handle this? Can it work with UTF16 F# files for example?

@Smaug123
Copy link
Contributor

Huh - if the F# compiler is not guaranteed to handle non-UTF8 files then that's a very strong argument that we should at least normalise to UTF-8. Whether to support other encodings as input really boils down to "how hard will it be"; if it's very easy, then it would kind of be nice to receive an arbitrary .txt file with F# code in, and be able to format it. But that does seem low priority if it's easier to assume UTF-8.

@nojaf nojaf requested a review from Smaug123 May 1, 2020 14:10
@nojaf nojaf merged commit 380262a into fsprojects:master May 3, 2020
@nojaf nojaf deleted the fix-795 branch May 3, 2020 16:34
@nojaf nojaf mentioned this pull request May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants