Skip to content

add UTF8 locale to build script.So file with nonEnglish chars can be …#52

Merged
srid merged 2 commits intosrid:masterfrom
platoali:utf8-locale-building
Nov 11, 2025
Merged

add UTF8 locale to build script.So file with nonEnglish chars can be …#52
srid merged 2 commits intosrid:masterfrom
platoali:utf8-locale-building

Conversation

@platoali
Copy link
Contributor

@platoali platoali commented Nov 5, 2025

this issue

files with None-ASCII charactes could not be generated. add UTF8 locale to nix build script.

Copy link
Owner

@srid srid left a comment

Choose a reason for hiding this comment

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

https://hackage.haskell.org/package/with-utf8 (blog post) is another way to solve this. Could you try it? Basically, you can wrap the main's body like here:

https://github.com/srid/haskell-template/blob/814a3c61fa12d0d87e7fa75608d5783005b53c76/src/Main.hs#L18-L19

If this works, you can update the PR accordingly.

@platoali
Copy link
Contributor Author

platoali commented Nov 5, 2025

I tried to wrap main with Utf8.withUtf8 without locale variable set in nix build.

main :: IO ()
main = Utf8.withUtf8 $   do
  cliArgs <- parseCliArgs
  let cfg = SiteConfig (cliArgsEmaCli cliArgs) def
  void $ Ema.runSiteWith @Route cfg cliArgs

and still got:

nix build .#site
 
## some generated stuff in between.

 > [Info#ema.generate] W /nix/store/n3nih0xn0hpkdklf3vqvjxm0xpq5wxkd-site/photo/2021-08-16___پشت کریمخانی.html
 > ema-template: /nix/store/n3nih0xn0hpkdklf3vqvjxm0xpq5wxkd-site/photo/2021-08-16___ .html: withBinaryFile: invalid argument (cannot encode character '\1662')

withBinaryFile is still not ok with non-ASCII characters in the file names. There is no difference with or without withUtf8

edit:

same result with withStdTerminalHandles .

@srid srid merged commit ab67d93 into srid:master Nov 11, 2025
1 check passed
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.

2 participants