jokesper · GitHub

@jokesper

@jokesper jokesper changed the title Implement encoding for -f *.rules Implement encoding in .rules

Jan 21, 2025

@simonmichael simonmichael added A-WISH

Some kind of improvement request or proposal.

i18n

Internationalisation/localisation-related.

csv

The csv file format, csv output format, or generally CSV-related.

labels

Jan 22, 2025

@jokesper

@jokesper

@jokesper

jokesper marked this pull request as ready for review

February 1, 2025 15:39

@jokesper

Instead of `text-icu` as [recommended by `text`](https://hackage.haskell.org/package/text-2.1.2/docs/Data-Text-Encoding.html):
> To gain access to a much larger family of encodings, use the `text-icu` package.
we use `encoding`, since `text-icu` requires an external library.
`encoding` does require a custom setup, which is currently
affected by a [bug in Cabal](haskell/cabal#6505)
but it doesn't require an external runtime dependency, which makes it
easier to distribute on macos and windows.
I also changed the `rReadFn` to get a `Handle` rather than a `Text`.
Such that we can use non standard functions for reading it.
This is kind of sideways, since the one place we care about it,
we don't use it at all. Though it still caused issues, since the input
wasn't parseable as text.
I think not using the handle has something to do with how `-` is treated
as stdin but I didn't do any further tests on that, since this is out of
the scope of this PR.

@jokesper

This makes sure we don't have to build a `build-type: Custom` package

simonmichael pushed a commit that referenced this pull request

Feb 16, 2025
…2319]
Previously, hledger could read CSV files containing non-ascii
characters only if they are UTF8-encoded.  Now there is a new CSV
rule, encoding ENCODING, which allows reading CSV files with other
encodings.
This adds a dependency on the encoding library, which supports fewer
encodings than text-icu but does not require a third-party C library.
To avoid build issues on various platforms, we require version 0.10+.
This adds some use of the ImplicitParams language extension, required
by encoding's API, but only in a small code region.
This also changes the type of Reader's rReadFn; it now takes
a `Handle` rather than a `Text`, allowing more flexibility.

Merged

Closed

Closed

Closed

Closed

Read the original on github.com ↗