2

i tried to convert from CP1256 to ISO-8859-6 encoding using Sygwin but it cannot convert!

and help?

$ iconv -f CP1256 -t ISO-8859-6 cca.txt > cca1.txt

iconv: cca.txt:791:41: cannot convert

the result of sed -n '791p' cca.txt | od -c

is enter image description here

1
  • Please post the output of this command: sed -n '791p' cca.txt | od -c
    – jlliagre
    Nov 3, 2013 at 23:20

1 Answer 1

3

If you look at the character maps for Windows-1256 and ISO-8859-6, you can see that 1256 has a character at every point, but 8859-6 has lots of gaps. So when converting, if there's a character that's not in the target encoding, iconv will complain.

Depending on which version of iconv you have, you may use the -c option, and those non-convertible characters will be dropped -- the file will get shorter. Or you can use something like --unicode-subst="@", which will substitute the invalid characters with @, which is convertible. Note that there is quite a bit of flexibility with that substitution, including expansion (e.g. "[%u]" will convert to the Unicode value in brackets).

If Cygwin does not have these options, you can try a recent Linux or Mac OS X.

In any case, the resulting file can only have characters that are actually in ISO-8859-6.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .