Where can I find the encodings supported by Text::CSV? Is "latin1" not supported or is the syntax wrong?
This does fail:
use Text::CSV;
spurt '/tmp/test.csv', 'ID;Gerät;Nr', :enc<latin1>;
slurp '/tmp/test.csv', :enc<latin1>; #ok
say csv :in</tmp/test.csv>, :encoding<latin1>, :sep_char<;>;
#Malformed UTF-8 error
There was an error in the code: the encoding declared was not actually used when opening the file. I created an issue in the module, and this pull request to fix it
It looks like the documentation for Text::CSV requires that the value passed to encoding must be the same as that accepted by the open function's encoding parameter.
The list of possible values is listed in the IO::Handle::encoding method documentation:
The accepted values for encoding are case-insensitive. The available encodings vary by implementation and backend. On Rakudo MoarVM the following are supported:
utf8utf16utf16leutf16beutf8-c8iso-8859-1windows-1251windows-1252windows-932asciiThe default encoding is
utf8, which undergoes normalization into Unicode NFC (normalization form canonical). In some cases you may want to ensure no normalization is done; for this you can useutf8-c8. Before usingutf8-c8please read Unicode: Filehandles and I/O for more information onutf8-c8and NFC.As of Rakudo 2018.04
windows-932is also supported which is a variant of ShiftJIS.Implementation may choose to also provide support for aliases, e.g. Rakudo allows aliases
latin-1foriso-8859-1encoding and dashed utf versions:utf-8andutf-16.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With