FSharp.Data icon indicating copy to clipboard operation
FSharp.Data copied to clipboard

CsvProvider encoding is not recognized

Open klinki opened this issue 3 years ago • 2 comments

Hello,

I'm trying to use CsvProvider with specified encoding, so the definition looks like this:

    type TradeRows = CsvProvider<csvDefinitionFile, Separators = ";", SkipRows = 3, HasHeaders = true, Encoding = "1250", Culture = "cs-CZ", IgnoreErrors = true>

but I'm getting following error during build:

No data is available for encoding 1250. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

Funny thing is this project works completely fine in Visual Studio, but I cannot build it with dotnet build or Rider.

I understand I have to register encodings with something like this:

Encoding.RegisterProvider CodePagesEncodingProvider.Instance

but how to do it so it is recognized by CsvProvider?

klinki avatar Jul 19 '22 19:07 klinki

I'm not actually sure. Perhaps we should just register all available encoding providers by default in the design-time component

dsyme avatar Aug 17 '22 10:08 dsyme

A partial fix to this is here: https://github.com/fsprojects/FSharp.Data/pull/1503

An additional package needs to be referenced, or we must move to later .NET for the design time component

dsyme avatar Mar 11 '24 22:03 dsyme