NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: iconv command problem



H Xu <xusubsc%gmail.com@localhost> wrote:

> On 2011/3/28 14:19, Marc Balmer wrote:
> > Am 28.03.11 08:06, schrieb H Xu:
> >>
> >> On both Linux and FreeBSD, the following command could be used to remove
> >> invalid characters:
> >>
> >> $ man cc | iconv -c
> >>
> >> However, on NetBSD, it seems that iconv doesn't support this kind of
> >> usage. Is there any solution?
> >
> > Actually it does work like you described.  -c is a valid option to iconv
> > in NetBSD and it does strip characters that it can not convert.
> >
>
> It gives the following on my NetBSD:
>
> % man cc | iconv -c
> Usage:  iconv [-cs] -f <from_code> -t <to_code> [file ...]
>          iconv -f <from_code> [-cs] [-t <to_code>] [file ...]
>          iconv -t <to_code> [-cs] [-f <from_code>] [file ...]
>          iconv -l
>
> Isn't it weird?

Seems you _have_ to specify the -f and -t codes:

ex. ascii to unicode:

        %  man cc > /tmp/test
        %  file /tmp/test
          /tmp/test: ASCII English text, with overstriking
        %  man cc | iconv -c -f ascii -t unicode > /tmp/test2
        %  file /tmp/test2
          /tmp/test2: Little-endian UTF-16 Unicode English character data, with 
overstriking

Guess the Linux version makes some assumptions about appropriate defaults?

Cheers,
Jeff W.


Home | Main Index | Thread Index | Old Index