-
Notifications
You must be signed in to change notification settings - Fork 26
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
Encoding-specific variants? #27
Comments
|
The hledger code is using decodeUtf8 $(makeRelativeToProject "embeddedfiles/hledger.1" >>= embedFile) To cut down on the duplication, hledger could defined it's own helper in a separate module: module TH where
...
embedFileText :: FilePath -> Q Exp
embedFileText filePath =
[| decodeUtf8 $(makeRelativeToProject filePath >>= embedFile) |] so you can use it like: $(embedFileText "embeddedfiles/hledger.1") |
I'd be in favor of deprecating |
Thanks for the response. Yes, I didn't think using |
I just ran into this issue. Perhaps it would be sufficient to just add a note to the It's not entirely obvious why Full error:
|
Using file-embed with non-ASCII files is rather fragile, as it depends on the build system's locale, and it doesn't work at all when building e.g. in a plain docker container (simonmichael/hledger#420 (comment)). In hledger, we've solved this by setting the handle encoding to UTF-8 prior to reading from it, which solved our problem.
I'm actually surprised that I haven't any issues here regarding this - maybe building in a pure Nix shell or a plain Docker container is not such a common scenario? Nevertheless, I think that extending the API with variants of the existing functions like
embedFile' :: TextEncoding -> FilePath -> Q Exp
and others would be a useful change not only for the hledger project.What do you think?
The text was updated successfully, but these errors were encountered: