iconv doesn't properly generate ascii

0

I have the following:

$ file DailyFollowUp.csv
DailyFollowUp.csv: Little-endian UTF-16 Unicode text, with very long lines, with CRLF, CR line terminators
$ iconv -c -t ascii DailyFollowUp.csv > output.txt
$ file output.txt
output.txt: data

I am expecting the output.txt file to give ASCII text as a result. Any idea why this isn't working?

This is on Cygwin64

Tom Ribbens

Posted 2014-01-06T16:35:16.453

Reputation: 372

You did not specified what encoding to convert from (-f). What is your locale? – choroba – 2014-01-06T16:39:48.677

locale is en_US.UTF-8 – Tom Ribbens – 2014-01-06T16:42:10.227

Then please provide the -f to iconv. – choroba – 2014-01-06T22:22:51.957

I did, and it did work, but I was hoping iconv would detect automatically the input. And if the source would ever change, it would still work. – Tom Ribbens – 2014-01-07T11:00:28.310

Check the man page of iconv: if -f is not given, it uses the current locale. – choroba – 2014-01-07T16:23:34.570

Answers

2

If you do not specify the input encoding via -f, iconv uses the current locale as the default. It does not do any auto-detection.

choroba

Posted 2014-01-06T16:35:16.453

Reputation: 14 741

0

Even I had the same problem. You have to specify the encoding type
http://lifepluslinux.blogspot.in/2014/09/convert-little-endian-utf-16-to-ascii.html

2991ambusher

Posted 2014-01-06T16:35:16.453

Reputation: 145