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

Use binary I/O for cabal files #142

Merged
merged 1 commit into from
Jan 8, 2017
Merged

Use binary I/O for cabal files #142

merged 1 commit into from
Jan 8, 2017

Conversation

snoyberg
Copy link
Contributor

@snoyberg snoyberg commented Jan 6, 2017

This makes character encoding of UTF-8 explicit, and avoids problems
when a different system locale is set. For more information, see:
http://www.snoyman.com/blog/2016/12/beware-of-readfile

This makes character encoding of UTF-8 explicit, and avoids problems
when a different system locale is set. For more information, see:
http://www.snoyman.com/blog/2016/12/beware-of-readfile
@snoyberg
Copy link
Contributor Author

snoyberg commented Jan 6, 2017

FYI, this came about when researching this build failure:

https://ci.appveyor.com/project/harendra-kumar/unicode-transforms/build/1.0.36

CC @harendra-kumar

@sol sol merged commit 219c435 into sol:master Jan 8, 2017
@sol
Copy link
Owner

sol commented Jan 8, 2017

@snoyberg thanks for the PR. I think there is at least one use of readFile somewhere too. Patches welcome.

snoyberg added a commit to commercialhaskell/stack that referenced this pull request Jan 11, 2017
@sol
Copy link
Owner

sol commented Dec 1, 2017

@snoyberg A side effect of this change is that we loose newline conversion on Windows.

While I assume it's sensible that the .cabal-file is encoded with UTF-8**, newline conversion is usually done by Git, so we may prefer to use the systems native newline handling when writing / reading files.

** Still, right now I'm puzzled what encoding Cabal uses when reading .cabal files...

@sol
Copy link
Owner

sol commented Dec 1, 2017

** Still, right now I'm puzzled encoding Cabal uses when reading .cabal files...

package.cabal:
    a Unicode UTF-8 text file containing a package description. For details of the syntax of this file, see the section on package descriptions.

https://www.haskell.org/cabal/users-guide/developing-packages.html#creating-a-package

So that is fine.

@tfausak
Copy link
Collaborator

tfausak commented Dec 1, 2017

Just chiming in to say that Cabal files are indeed UTF-8 in practice (with one exception). The currently unreleased Parsec-based parser will use byte strings instead of strings. That explicitly uses UTF-8 behind the scenes.

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