1829166 Members
2293 Online
109986 Solutions
New Discussion

Re: iconv command

 
LucianoCarvalho
Respected Contributor

iconv command

Hi Guys,

I'm tryng to run the commad below, but the system is given me an error:

#iconv -f cp1252 -t iso81 arq.txt > new-arq.txt
iconv: can not initialize the conversion

Any idea?

3 REPLIES 3
Ivan Krastev
Honored Contributor

Re: iconv command

Check for any special symbols in input file.

From iconv man - http://www.docs.hp.com/en/B9106-90007/iconv.1.html

If an input character does not belong to the code set selected by the -f option (the "from" code set), the command terminates.


regards,
ivan
LucianoCarvalho
Respected Contributor

Re: iconv command

Hi,

The codes cp1252 and iso81 are configured in file /usr/lib/nls/iconv/config.iconv.
Do I have to do anything else to get this conversion working?

thanks.
Dennis Handly
Acclaimed Contributor

Re: iconv command

>The codes cp1252 and iso81 are configured in file /usr/lib/nls/iconv/config.iconv.
>Do I have to do anything else to get this conversion working?

I believe you can only convert from A to B if both of those are on the same line. For your two:
$ grep ^cp1252 /usr/lib/nls/iconv/config.iconv
cp1252 ucs2 cp1252=ucs2 lsbucs2.sl
cp1252 utf8 cp1252=ucs2 lsbutf8.sl
$ grep " iso81 " /usr/lib/nls/iconv/config.iconv
(The above has tabs before and after.)
...
ucs2 iso81 ucs2=iso81 lucs2hp.sl
utf8 iso81 ucs2=iso81 lutf8hp.sl

So you would need:
$ iconv -f cp1252 -t ucs2 arq.txt |
iconv -t iso81 -f ucs2 > new-arq.txt