Using linux-x86_64 with a fresh install of Ubuntu Lunar 23.04.
GHC 9.4.6 installed via the Nix package manager.
Hledger also installed via Nix, at 1.30.1.
Problem
Running hledger bs on a file containing € characters:
hGetContents: invalid argument (cannot decode byte sequence starting from 226)
Solution
€ is a utf8 character and so should be treated as utf8 not ascii.
My solution, based on Nix issue NixOS/nixpkgs#64603 and Nix documentation https://nixos.org/manual/nixpkgs/stable/#locales was to update my ~.profile with:
export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive
And restart computer, or > source ~/.profile
After that hledger bs was correctly reporting my balance.
Proposed documentation update in manual
In the manual, it might be worth adding this Nix specific case:
If you are using Nix (not NixOS) for GHC and Hledger, you might need to set the LOCALE_ARCHIVE variable
$ echo "export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive" >>~/.profile
# close and re-open terminal window
Which could go underneath where you currently have:
$ echo "export LANG=en_US.utf8" >>~/.profile
# close and re-open terminal window
Using linux-x86_64 with a fresh install of Ubuntu Lunar 23.04.
GHC 9.4.6 installed via the Nix package manager.
Hledger also installed via Nix, at 1.30.1.
Problem
Running hledger bs on a file containing € characters:
hGetContents: invalid argument (cannot decode byte sequence starting from 226)
Solution
€ is a utf8 character and so should be treated as
utf8notascii.My solution, based on Nix issue NixOS/nixpkgs#64603 and Nix documentation https://nixos.org/manual/nixpkgs/stable/#locales was to update my
~.profilewith:export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archiveAnd restart computer, or
> source ~/.profileAfter that
hledger bswas correctly reporting my balance.Proposed documentation update in manual
In the manual, it might be worth adding this Nix specific case:
If you are using Nix (not NixOS) for GHC and Hledger, you might need to set the LOCALE_ARCHIVE variable
$ echo "export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive" >>~/.profile# close and re-open terminal windowWhich could go underneath where you currently have:
$ echo "export LANG=en_US.utf8" >>~/.profile# close and re-open terminal window